-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.js
43 lines (31 loc) · 1.16 KB
/
app.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
42
43
const express = require('express');
const path = require('path');
const favicon = require('serve-favicon');
const logger = require('morgan');
const bodyParser = require('body-parser');
const nconf = require('nconf');
const fs = require('fs');
if (!fs.existsSync('./config.json')) {
console.error('\n\n--\nERROR: Missing config file.\nIf running in development, Make sure to create a config.json in the repo root. Ask an author for its contents.\nIn production, config variables are specified via the Heroku web interface.\n\n')
}
nconf
.argv()
.env()
.file({file: './config.json'});
const app = express();
const routes = require('./routes');
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', routes.index);
app.get('/terms', routes.terms);
app.get('/api', routes.api);
app.post('/api/feedback', routes.feedback);
// error handlers
require('./libs/errors')(app);
module.exports = app;