forked from vacationroulette/vacationroulette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (30 loc) · 945 Bytes
/
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
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var app = express();
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
var fs = require('fs');
if (fs.existsSync('./config.json')) {
app.config = require('./config.json');
} else {
app.config = {
"client_id": process.env.CLIENT_ID,
"client_secret": process.env.CLIENT_SECRET,
"uri": process.env.URI
};
}
app.api = require('./api/index')(app);
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
if (err) console.log('Error: ' + err);
});
module.exports = app;