-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.ts
41 lines (34 loc) · 1.19 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
import * as express from 'express';
import * as bodyParser from 'body-parser'
import * as mongoose from 'mongoose';
import * as cors from 'cors';
import articleRoutes from './src/routes/articles';
import noteRoutes from './src/routes/notes';
import transactionRoutes from './src/routes/transactions';
import userRoutes from './src/routes/users';
class App {
public app: express.Application = express();
public constructor() {
this.configure();
App.configureDatabase();
}
private configure(): void {
this.app.use(cors());
this.app.use(bodyParser.urlencoded({
extended: false
}));
this.app.use(bodyParser.json());
this.app.use('/articles', articleRoutes);
this.app.use('/notes', noteRoutes);
this.app.use('/transactions', transactionRoutes);
this.app.use('/users', userRoutes);
}
private static configureDatabase(): void {
mongoose.connect('mongodb+srv://stock-exchange:stock-exchange@stock-exchange-btfeh.mongodb.net/' +
'test?retryWrites=true&w=majority', {
useNewUrlParser: true,
useCreateIndex: true
});
}
}
export default new App().app;