-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.ts
27 lines (23 loc) · 858 Bytes
/
server.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
import * as bodyParser from 'body-parser';
import * as cookieParser from 'cookie-parser';
import * as express from 'express';
import * as morgan from 'morgan';
import config from './config/main';
import { Router } from './router/route.routes';
export class server {
constructor() {
const app = express();
const routes = new Router().getRoutes();
//express middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(new cookieParser());
app.use(morgan('dev'));
app.use('/api', routes);
app.listen(config.port, () => {
console.log(`server running at http://${config.database.host}:${config.port}`);
console.log(`api running at http://${config.database.host}:${config.port}/api`);
});
}
};
new server();