-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
42 lines (37 loc) · 943 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
32
33
34
35
36
37
38
39
40
41
42
import 'reflect-metadata';
import { createExpressServer, useContainer } from 'routing-controllers';
import Container from 'typedi';
// must import data source before using repositories
import { dataSource } from './DataSource';
import { controllers } from './api/controllers';
import { middlewares } from './api/middleware';
import { Config } from './config';
useContainer(Container);
dataSource
.initialize()
.then(() => {
console.log('Initialized TypeORM DataSource');
})
.catch((error) => {
console.log(error);
});
const app = createExpressServer({
cors: true,
routePrefix: '/api/v1',
controllers,
middlewares,
defaults: {
paramOptions: {
required: true,
},
},
validation: {
whitelist: true,
skipMissingProperties: true,
forbidUnknownValues: true,
},
defaultErrorHandler: false,
});
app.listen(Config.port, () => {
console.log(`Listening on port ${Config.port}...`);
});