-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (32 loc) · 1.1 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
37
38
39
40
41
'use strict';
const env = process.env.NODE_ENV || 'development';
//use a local .env for local development
//production builds should be using environment vars from docker
if (env === 'development') {
console.log('looking for local .env file');
require('dotenv').config();
}
const path = require('path');
const express = require('express');
const mustacheExpress = require('mustache-express');
const middleware = require('./middleware');
const bodyParser = require('body-parser');
const neDbController = require('./nedb-controller');
const pgController = require('./pg-controller');
const app = express();
app.use(bodyParser.json());
app.engine('html', mustacheExpress());
app.set('view engine', 'html');
app.set('views', path.join(__dirname, '/client/html'));
app.use(express.static(path.join(__dirname, '/client/js')));
//smoke test
app.get(['/', '/hai'], (req, res) => {
res.render('hello-docker');
});
//nedb demo
app.use('/nedb', neDbController);
//postgres demo
app.use('/pg', pgController);
app.use(middleware.errorMiddleware);
app.listen(9000);
console.log(`app listening on port 9000 in [${env}] mode`);