-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
33 lines (29 loc) · 795 Bytes
/
index.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
import grant from './src/middlewares/grant'
import avi from './src/middlewares/avi'
import * as session from 'koa-session'
import * as logger from 'koa-logger'
import * as koaBody from 'koa-body'
import router from './src/routers/'
import * as cors from '@koa/cors'
import * as config from 'config'
import * as Koa from 'koa'
import './src/utils/db'
const PORT = config.get('PORT')
// should be same as nginx conf
const FILE_SIZE_LIMIT = '200mb'
const app = new Koa()
app.keys = ['avi']
app.use(avi)
app.use(session(app))
app.use(koaBody({
formLimit: FILE_SIZE_LIMIT,
formidable: { maxFieldsSize: 200 * 1024 * 1024 },
multipart: true
}))
app.use(cors({ credentials: true }))
app.use(logger())
app.use(grant)
app
.use(router.routes())
.use(router.allowedMethods())
app.listen(PORT)