-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
50 lines (39 loc) · 1.13 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
44
45
46
47
48
49
50
'use strict';
const config = require('./config');
if (config.env === 'development') {
process.env.DEBUG = 'fd:*';
}
const debug = require('debug')('fd:app'),
express = require('express'),
bodyParser = require('body-parser'),
morgan = require('morgan'),
mongoose = require('./mongoose'),
app = express();
global.timers = [];
if (config.env === 'development') {
app.use(morgan('dev', {
immediate : true
}));
}
app.use(bodyParser.urlencoded({
extended : true
}));
app.use(bodyParser.json());
debug('Connecting to database connection...');
const connection = mongoose.connect();
const start = function () {
debug('Setting up git config..');
const childProcess = require('child_process');
childProcess.execSync('git config --global user.name "Flickr Downloadr Webhook"');
childProcess.execSync('git config --global user.email "contact.us@flickrdownloadr.com"');
debug('Setting up routes..');
require('./routes')(app);
app.listen(config.port);
console.log('Listening on port %d', config.port);
};
exports.app = app;
exports.connection = connection;
exports.start = start;
if (config.env !== 'test') {
start();
}