-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
37 lines (29 loc) · 1.11 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
import express, { Request, Response, NextFunction, Application } from 'express';
import 'dotenv/config';
import { errorHandler } from './middleware/error';
const bodyParser = require('body-parser');
const app: Application = express();
app.use( (req: Request, res: Response, next: NextFunction) => {
res.set({
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Origin,X-Requested-With,Content-Type,Accept,Authorization',
'Access-Control-Allow-Methods': 'POST,PUT,GET,OPTIONS',
'Content-Type': 'application/json; charset=utf-8'
});
next();
} );
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json({limit: '200mb'}));
import router = require('./urls');
const versionNumber: number = 1;
app.use(`/api/v${versionNumber}/kolohack`, router.router);
app.use(errorHandler);
const PORT: number = process.env.PORT === undefined ? 3000 : +process.env.PORT;
// serve the services
app.listen(
PORT,
() => {
console.log(`'Server running in ${process.env.NODE_ENV} mode on port ${PORT}`);
}
);