-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (24 loc) · 686 Bytes
/
Copy pathapp.js
File metadata and controls
34 lines (24 loc) · 686 Bytes
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
'use strict'
const Koa = require('koa'),
router = require('koa-router')(),
render = require('koa-art-template'),
path = require('path');
//引入路由子模块
const admin = require('./routes/admin.js')
const api = require('./routes/api.js')
const index = require('./routes/index.js')
const app = new Koa()
//配置 koa-art-template 模板引擎
render(app, {
root: path.join(__dirname, 'views'),
extname: '.html',
debug: process.env.NODE_ENV !== 'production'
});
// 配置层级路由
router.use('/', index)
router.use('/admin', admin)
router.use('/api', api)
//启动路由
app.use(router.routes())
app.use(router.allowedMethods())
app.listen(8008)