-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
38 lines (30 loc) · 942 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const convert = require('koa-convert');
const koa = require('koa');
const app = new koa();
const router = require("./router/router.js");
const serve = require('koa-serve');
const logger = require('koa-logger');
const body = require('koa-better-body');
const fs = require('fs-promise');
const path = require('path');
// Database
const db = require("./model");
app.context.db = db;
const jsonModel = require("./model/json");
app.context.jsonModel = jsonModel;
// Config
const config = require('./config');
app.keys = config.keys;
app.context.cfg = config;
if (config.debug){
app.use(convert(logger()));
}
app.use(convert(serve('asset')));
app.use(convert(body()));
app.use(router.routes());
app.use(router.allowedMethods());
//创建 upload 目录结构
fs.ensureDir(path.join(config.uploadPath,'team'));
fs.ensureDir(path.join(config.uploadPath,'deleted'));
fs.ensureDir(path.join(config.uploadPath,'export'));
module.exports=app;