forked from brennentsmith/internet-speed-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (30 loc) · 1.24 KB
/
index.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
/* eslint-disable no-console */
const path = require('path');
const config = require('config');
const express = require('express');
const compression = require('compression');
const morgan = require('morgan');
const listenPort = config.get('webserver.listenPort');
const listenHost = config.get('webserver.listenHost');
const app = express();
app.use(morgan('combined'));
app.enable('etag');
app.use(compression());
// Static routes
app.get('/', (req, res) => {
res.sendFile(path.join(`${__dirname}/views/index.html`));
});
app.use('/styles/', express.static(path.join(`${__dirname}/styles`)));
app.use('/scripts/', express.static(path.join(`${__dirname}/scripts`)));
app.use('/scripts/vis/', express.static(path.join(`${__dirname}/node_modules/vis-charts/dist/`)));
app.use('/scripts/jquery/', express.static(path.join(`${__dirname}/node_modules/jquery/dist/`)));
const dbInit = require('./db');
const routes = require('./routes/app');
dbInit().then((dbs) => {
// Initialize the application once database connections are ready.
routes(app, dbs).listen(listenPort, listenHost, () => console.log(`Listening on port ${listenPort}`));
}).catch((err) => {
console.error('Failed to make all database connections!');
console.error(err);
process.exit(1);
});