-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (29 loc) · 794 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
38
39
40
41
42
43
44
45
46
47
48
require('@babel/register')
// require('./app.js')
const Koa = require('koa')
const bodyParser = require('koa-bodyparser');
const router = require('./middleware/router')()
const apiDoc = require('./middleware/apiDoc')
const app = new Koa()
// app.use(async (ctx,next) => {
// ctx.throw(500);
// });
// app.use( async (ctx,next)=>{
// await next()
// ctx.body ={ msg:'hello,world' }
// })
// app.use(async (ctx, next)=> {
// await next();
// ctx.status = 404
// ctx.body="404页面"
// });
// router.get('/s', (ctx,next)=>{
// ctx.body = 'hello Router'
// })
app.use(bodyParser())
apiDoc(router);
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(3000,()=>{
console.log('server is running at http://localhost:3000')
})