-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
68 lines (29 loc) · 961 Bytes
/
app.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Created by zhoucaiguang on 2017/3/24.
*/
import * as koa from 'koa';
import * as koaRouter from 'koa-router';
import * as logger from 'koa-logger';
import Router from './route';
import * as log4 from 'log4js';
import {log4Config} from './configs/log4';
const app = new koa();
const bodyParser = require('koa-body');
log4.configure(log4Config);
const log = log4.getLogger();
const koaRoute = new koaRouter();
app.use(logger());
app.use(bodyParser());
app.use(koaRoute.routes());
koaRoute.use(async (ctx,next)=> {
ctx.set("Access-Control-Allow-Origin", "*");
ctx.set("Access-Control-Allow-Headers", "X-Requested-With");
ctx.set("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
ctx.set("Content-Type", "application/json;charset=utf-8");
await next();
});
new Router(koaRoute);
app.listen(3003);
// app.listen(3004);
// app.listen(3005);
console.log('服务开启,端口号:3003');