-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (23 loc) · 755 Bytes
/
app.js
File metadata and controls
32 lines (23 loc) · 755 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
const Koa = require('koa2')
const cors = require('koa2-cors')
const path = require('path')
const koa_static = require('koa-static')
const koa_jwt = require('koa-jwt')
const jwt_auth = require('./middlewares/jwt-auth')
const logger = require('./middlewares/log')
const koa_jsonp = require('koa-jsonp')
const { appPort, jwtSecret } = require('./config')
const router = require('./router/index')
const app = new Koa()
app.use(logger)
app.use(koa_jwt({ secret: jwtSecret }).unless({
path: [/^\/auth\//]
}))
app.use(jwt_auth)
app.use(koa_jsonp())
app.use(cors())
app.use(koa_static(path.join(`${__dirname}/public`)))
app.use(router.routes(), router.allowedMethods())
app.listen(appPort, () => {
console.log(`app started at port ${appPort}...`)
})