forked from coolstore-demo/web-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
39 lines (29 loc) · 1.06 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
38
39
'use strict';
const path = require("path");
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const cors = require('cors');
const probe = require('kube-probe');
// Environment Variables
const gulp = require('gulp'); // Load gulp
const gulpfile = require('./gulpfile'); // Loads our config task
// Kick of gulp 'config' task, which generates angular const configuration
gulp.series(gulp.task('config'))();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
// Enable CORS support
app.use(cors());
// Add the ability to force the application into a degraded state
require('./middleware/boom')(app)
// error handling
app.use(function(err, req, res, next) {
console.error(err.stack);
res.status(500).send('Something bad happened!');
});
app.use('/', express.static(path.join(__dirname, 'views')));
app.use('/app', express.static(path.join(__dirname, 'app')));
app.use('/node_modules', express.static(path.join(__dirname, 'node_modules')));
// Add a health check
probe(app);
module.exports = app;