-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
23 lines (23 loc) · 844 Bytes
/
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
const express = require('express');
const path = require('path');
const https = require('https');
const fs = require('fs');
const bodyParser = require('body-parser');
const api = require('./src/server/routes/api');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'dist')));
app.use('/api', api);
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'dist/index.html'));
});
const port = process.env.PORT || '3001';
app.set('port', port);
var privateKey = fs.readFileSync( 'smartsdkitesm.key.pem' );
var certificate = fs.readFileSync( 'smartsdkitesm.crt.pem' );
const server = https.createServer({
key: privateKey,
cert: certificate
}, app);
server.listen(port, function(){console.log('API running on localhost:${port}')});