-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (36 loc) · 1.09 KB
/
index.js
File metadata and controls
47 lines (36 loc) · 1.09 KB
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
42
43
44
45
46
47
/**
* Created by Henrik Peinar on 01/04/16
*/
'use strict';
const express = require('express');
const config = require('easy-config');
const bunyan = require('bunyan');
const log = bunyan.createLogger({name: "stardrew"});
const bodyParser = require('body-parser');
const app = express();
const favicon = require('serve-favicon');
app.enable('trust proxy');
// increased bodyParser limit to allow big farms
app.use(bodyParser.json({limit: '25mb'}));
app.use((req, res, next) => {
req.log = log;
next();
});
app.use(favicon(__dirname + '/public/favicon.ico'));
// currently nothing is at root, redirect use directly to planner
// app.get('/', (req, res) => {
// res.redirect('/planner');
// });
// mount api endpoints
app.use('/api', require('./routes')());
// heartbeat endpoint for pinging applications
app.get('/heartbeat', (req, res) => {
res.sendStatus(200);
});
// static mounts
app.use(express.static('./public'));
app.use('/planner/:id', express.static('./public/planner'));
// run express
app.listen(config.port, () => {
log.info('App listening on port', config.port);
});