-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (26 loc) · 1.01 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
const express = require('express');
const http = require('http');
const https = require('https');
const cors = require('cors');
const path = require('path');
const bodyParser = require('body-parser');
const api = require("./api");
const { secretKeyAuthorization } = require('./authorization');
const { sslCredentials } = require('./ssl-credentials');
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use('/', express.static(path.join(__dirname, 'public')));
app.use('/api', secretKeyAuthorization, api)
const httpServer = http.createServer(app);
const httpsServer = https.createServer(sslCredentials, app);
const HTTP_PORT = process.env.HTTP_PORT || 8080;
const HTTPS_PORT = process.env.HTTPS_PORT || 8443;
httpServer.listen(HTTP_PORT, () => {
console.log("DIALOGFLOW ARTILLERY DELEGATE");
console.log(`app listening on port ${HTTP_PORT}`);
});
httpsServer.listen(HTTPS_PORT, () => {
console.log("DIALOGFLOW ARTILLERY DELEGATE SSL");
console.log(`app listening on port ${HTTPS_PORT}`);
});