-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
39 lines (33 loc) · 1.46 KB
/
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
import cookieParser from 'cookie-parser';
import express from 'express';
import sessionPopulate from 'rm-session-populator';
import expressConfig from './src/configs/config.express';
import configSessionPopulator from './src/configs/config.sessionPopulator';
import routeMain from './src/routes/route.main';
import { createInternalPermissionRouter, createPermissionRouter } from './src/routes/route.permissions';
import routeRoleAssignments from './src/routes/route.roleAssignments';
import routeRoles from './src/routes/route.roles';
import grantPreflight from './src/services/middleware/grantPreflight';
import setCorsHeaders from './src/services/middleware/setCorsHeaders';
import { connectToDb } from './src/services/mongodb/service.mongodbConnector';
const app = express();
app.use(setCorsHeaders);
app.use(grantPreflight);
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
app.use(cookieParser());
app.use(sessionPopulate(configSessionPopulator));
// Connect To Database
connectToDb();
// Routes
app.use('/api/admin/internalPermissions', createInternalPermissionRouter());
app.use('/api/admin/permissions', createPermissionRouter());
app.use('/api/admin/roles', routeRoles);
app.use('/api/admin/roleAssignments', routeRoleAssignments);
app.use('/api/v1', routeMain);
app.use('/', (_, res) => res.send('<h1>Query Bouncer is running!</h1>'));
app.listen(expressConfig.httpPort, () => {
console.log(`HTTP Server listening on ${expressConfig.httpPort}`);
});