-
Notifications
You must be signed in to change notification settings - Fork 17
/
app.ts
30 lines (27 loc) · 795 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
import Koa from 'koa'
import bodyParser from 'koa-bodyparser'
import cors from 'koa-cors'
import { createConnection } from 'typeorm'
import 'reflect-metadata'
import config from './config'
import errorHandle from './middleware/errorHandle'
import router from './routes/index'
import { ormOptions } from './service/orm'
import { scanInvoices } from './service/cron'
const app = new Koa()
createConnection(ormOptions)
.then(() => {
app
.use(cors())
.use(bodyParser())
.use(errorHandle())
.use(router.routes())
.use(router.allowedMethods())
app.listen(config.connection.port, () => {
console.log(`Listening on ${config.connection.port}.`)
})
scanInvoices.start()
})
.catch((err) => {
console.log(`Initialization error: ${err}`)
})