-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (34 loc) · 1.26 KB
/
app.js
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
42
const express = require('express');
const DB = require('./classes/Database');
const swaggerUi = require('swagger-ui-express');
const swaggerDocs = require('./classes/SwaggerConfig');
require('dotenv').config();
// Check is we in dev mode
const isDev = process.env.DEV == "true" ? true : false;
// Require needed files
const bodyParser = require('body-parser');
const credentialsRoute = require('./routes/addUser');
const health = require('./routes/health');
const getIosSecrets = require('./routes/getSecretFilesIos');
const getCommonSecrets = require('./routes/getSecretFilesCommon');
const getStrongswanSecrets = require('./routes/getSecretFielsStrongswan');
const revokeUser = require('./routes/revokeUser');
// Database
DB.Connect();
// Server configs
const app = express();
const PORT = process.env.PORT; // Choose any port you prefer
// Middleware to parse application/json
app.use(bodyParser.json());
// Mounting the route handlers
app.use(credentialsRoute);
app.use(getIosSecrets);
app.use(getCommonSecrets);
app.use(getStrongswanSecrets);
app.use(revokeUser);
app.use(health);
if(isDev) app.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
// Start the server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});