-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
46 lines (38 loc) · 1.02 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* @Version: 0.0.0.1
* @LastEditor: Kian
* @Date: 2021-09-14 16:04:11
* @LastEditTime: 2021-09-16 17:09:31
*/
import Koa from "koa";
import router from './routers/index'
import { koaSwagger } from 'koa2-swagger-ui';
import bodyParser from 'koa-bodyparser'
import cors from '@koa/cors'
const { accessLogger } = require('./config/logger')
const app: Koa = new Koa();
app.use(accessLogger())
app.use(bodyParser())
app.use(cors());
app.use(router.routes());
app.use(router.allowedMethods());
app.use(
koaSwagger({
routePrefix: '/swagger', // host at /swagger instead of default /docs
swaggerOptions: {
url: '/swagger.json', // example path to json
showRequestHeaders: true,
layout: "StandaloneLayout",
docExpansion: "none",
},
exposeSpec: true,
hideTopbar: true
}),
);
const port = process.env.PORT || 3030;
const host = process.env.HOST || "http://localhost"
app.listen(port, () => {
console.log(`seccess start server`)
console.log(`local: ${host}:${port}`)
})
module.exports = app