-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
34 lines (27 loc) · 1.05 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
// TODO - em construção.
// Favor utilizar mecanismos de testes para validar aplicação.
// npx ts-node index.ts
import express from 'express';
import bodyParser from 'body-parser'
import cors from 'cors'
import { ChangeLogRoute } from './src/routes/ChangeLogRoute';
import ChangeLogGeneratorService from './src/services/ChangeLogGeneratorService';
import ErrorMiddleware from './src/error/ErrorMiddleware';
const app = express();
app.use(cors())
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
let changeLogRoute = new ChangeLogRoute(new ChangeLogGeneratorService());
// public
app.use('/change-log', changeLogRoute.montaRotas());
app.use(ErrorMiddleware.handler)
const port = process.env.PORT || 5000;
if (process.env.NODE_ENV !== 'test') {
app.listen(port, () => console.info('App started on port -> ' + port));
}
export default app;