blob: 7bbe31c12031a88ee933dd687403bf92baf5131c (
plain) (
blame)
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
|
import * as express from 'express';
import * as logger from 'morgan';
import * as bodyParser from 'body-parser';
import FileRouter from './FileRouter';
class App {
public express
public log_enabled : boolean;
constructor () {
this.express = express()
this.middleware()
this.mountRoutes()
}
// Configure Express middleware.
private middleware(): void {
console.log(this.log_enabled);
if(this.log_enabled) this.express.use(logger('combined'));
this.express.use(bodyParser.json());
this.express.use(bodyParser.urlencoded({ extended: false }));
}
// Configure API endpoints.
private mountRoutes (): void {
const defRouter = express.Router()
defRouter.get('/', (req, res) => {
res.json({
message: 'Welcome to the CS3099 BE4 server!'
})
})
this.express.use('/', defRouter)
this.express.use('/cs3099group-be-4', FileRouter)
}
}
export default new App().express
|