-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
50 lines (44 loc) · 1.58 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import express from 'express';
import morgan from 'morgan';
import cookieParser from 'cookie-parser';
import { createConnection, getConnectionOptions } from 'typeorm';
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
import { createExpressServer } from 'routing-controllers';
import { logger } from './source/infrastructure/logger';
import { loginRouter } from './source/application/routes/loginRouter';
import { employeeRouter } from './source/application/routes/employeeRouter';
import { workStageSpanRouter } from './source/application/routes/workStageSpanRouter';
import { scheduleRouter } from './source/application/routes/scheduleRouter';
import { homeRehabilitationRouter } from './source/application/routes/homeRehabilitationRouter';
import { commentRouter } from './source/application/routes/commentRouter';
import { vacationRouter } from './source/application/routes/vacationRouter';
import dotenv from 'dotenv';
dotenv.config();
const server = createExpressServer({
// controllers:[],
// cors: true,
});
server.use(express.json(), morgan('dev'), cookieParser());
server.use(
'/api',
loginRouter,
employeeRouter,
workStageSpanRouter,
homeRehabilitationRouter,
scheduleRouter,
commentRouter,
vacationRouter
);
const PORT = process.env.PORT || 4000;
server.listen(PORT, async () => {
const connectionOptions = await getConnectionOptions();
Object.assign(connectionOptions, {
namingStrategy: new SnakeNamingStrategy(),
});
try {
await createConnection(connectionOptions);
console.log(`Server is listening on port ${PORT}`);
} catch (error) {
logger.error(error);
}
});