forked from SoulSwapFinance/soul-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
31 lines (24 loc) · 747 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
'use strict';
const Koa = require('koa');
const helmet = require('koa-helmet');
const body = require('koa-bodyparser');
const cors = require('@koa/cors');
const conditional = require('koa-conditional-get');
const etag = require('koa-etag');
const rt = require('./middleware/rt');
const powered = require('./middleware/powered');
const router = require('./router');
const index = new Koa();
index.use(rt);
index.use(conditional());
index.use(etag());
index.use(helmet());
index.use(cors({ origin: '*' }));
index.use(powered);
index.use(body());
index.context.cache = {};
index.use(router.routes());
index.use(router.allowedMethods());
const port = process.env.PORT || 3002;
index.listen(port);
console.log(`> soul-api running! (:${port})`);