|
@@ -8,7 +8,7 @@ import bodyParser from 'koa-bodyparser';
|
|
|
|
|
|
import helmet from 'koa-helmet';
|
|
import helmet from 'koa-helmet';
|
|
|
|
|
|
-import koaStatic from 'koa-static'
|
|
+import koaStatic from 'koa-static';
|
|
|
|
|
|
import koaProxy from 'koa-proxies';
|
|
import koaProxy from 'koa-proxies';
|
|
import controllers from './controllers';
|
|
import controllers from './controllers';
|
|
@@ -20,6 +20,8 @@ import responseMiddleware from './middlewares/response';
|
|
import sessionMiddleware from './middlewares/session';
|
|
import sessionMiddleware from './middlewares/session';
|
|
import authMiddleware from './middlewares/auth';
|
|
import authMiddleware from './middlewares/auth';
|
|
|
|
|
|
|
|
+import { loggerInstance } from './utils/logger';
|
|
|
|
+
|
|
const app = new Koa<DefaultState, Context>();
|
|
const app = new Koa<DefaultState, Context>();
|
|
|
|
|
|
|
|
|
|
@@ -58,6 +60,10 @@ app.use(koaProxy('/proxy', {
|
|
|
|
|
|
app.on('error', (err, ctx: Context) => {
|
|
app.on('error', (err, ctx: Context) => {
|
|
ctx.$response(err, 'error', false);
|
|
ctx.$response(err, 'error', false);
|
|
|
|
+ const errMsg: string = err.message || '服务出错';
|
|
|
|
+ console.log(errMsg);
|
|
|
|
+ console.log(ctx);
|
|
|
|
+ loggerInstance(ctx).error(errMsg)
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|