-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.ts
executable file
·35 lines (23 loc) · 965 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
28
29
30
31
32
33
34
35
import * as express from "express";
import * as path from 'path';
import {bootstrap} from './bootstrap/app';
//!IMPORTANT :load the environment config first before importing other user custom modules
bootstrap();
import apiRouter from "./routes/api-main";
import webRoutes from "./routes/web-main";
import {validateJWTTokenMiddleware} from './app/middleware/auth-middleware'
const port = process.env.PORT || 3000;
const app = express();
//Middleware definitions
app.disable('x-powered-by');
app.use(express.json()); //form data to json
app.use(express.urlencoded({extended: true})); //support for multiform data
app.use(express.static(path.join(__dirname, 'public')));
app.use(validateJWTTokenMiddleware); // Token Authentication middleware
//router definition
app.use('/api/v1', apiRouter); // API endpoint
app.use('/web', webRoutes); // web endpoints
//launch the server
app.listen(port, () => {
console.log(`server running at port ${port}`);
});