-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (31 loc) · 1.19 KB
/
server.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
require('dotenv').config();
const utilities = require("./misc/utilities");
const logger = utilities.getLogger();
const https = require('https');
const fs = require('fs');
// https
const httpsOptions = {
key: fs.readFileSync('keys/privkey.pem'),
cert: fs.readFileSync('keys/fullchain.pem')
};
// express makes web services for node easy
const express = require('express');
// init the express
const cors = require('cors');
const app = express();
app.use(express.json());
app.use(cors());
// hook up the routers
// property router handles all the routes that work with properties
const empRouter = require('./routes/emp');
app.use('/emp', empRouter);
// swagger router handles any swagger calls
const swaggerRouter = require('./routes/swagger');
app.use('/swagger', swaggerRouter);
// hello is misc functionality so throw it in its own router
const helloRouter = require('./routes/hello');
app.use('/hello', helloRouter);
https.createServer(httpsOptions, app).listen(process.env.HTTPS_LISTEN_PORT, function () {
console.log('API server is listening on port ' + process.env.HTTPS_LISTEN_PORT + '...');
logger.info('API server is listening on port ' + process.env.HTTPS_LISTEN_PORT + '...');
});