Cleanup src/app.js
This commit is contained in:
parent
7920eebd4b
commit
92e5db544a
@ -21,6 +21,7 @@ const co = require('co');
|
|||||||
const app = require('koa')();
|
const app = require('koa')();
|
||||||
const log = require('npmlog');
|
const log = require('npmlog');
|
||||||
const config = require('config');
|
const config = require('config');
|
||||||
|
const serve = require('koa-static');
|
||||||
const router = require('koa-router')();
|
const router = require('koa-router')();
|
||||||
const util = require('./service/util');
|
const util = require('./service/util');
|
||||||
const Mongo = require('./dao/mongo');
|
const Mongo = require('./dao/mongo');
|
||||||
@ -82,9 +83,7 @@ app.use(function *(next) {
|
|||||||
this.set('Access-Control-Allow-Origin', '*');
|
this.set('Access-Control-Allow-Origin', '*');
|
||||||
this.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
this.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||||
this.set('Access-Control-Allow-Headers', 'Content-Type');
|
this.set('Access-Control-Allow-Headers', 'Content-Type');
|
||||||
this.set('Cache-Control', 'no-cache');
|
|
||||||
this.set('Connection', 'keep-alive');
|
this.set('Connection', 'keep-alive');
|
||||||
|
|
||||||
yield next;
|
yield next;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -92,7 +91,7 @@ app.use(router.routes());
|
|||||||
app.use(router.allowedMethods());
|
app.use(router.allowedMethods());
|
||||||
|
|
||||||
// serve static files
|
// serve static files
|
||||||
app.use(require('koa-static')(__dirname + '/static'));
|
app.use(serve(__dirname + '/static'));
|
||||||
|
|
||||||
app.on('error', (error, ctx) => {
|
app.on('error', (error, ctx) => {
|
||||||
if (error.status) {
|
if (error.status) {
|
||||||
|
Loading…
Reference in New Issue
Block a user