-
Notifications
You must be signed in to change notification settings - Fork 11
/
app.js
51 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
51
'use strict';
/*
Kent Hack Enough
Let's try to organize organizing.
@author Paul Dilyard
*/
global.rootRequire = function(name) {
return require(__dirname + '/' + name);
};
let express = require('express');
let socketio = require('socket.io');
let mongoose = require('mongoose');
let config = require('./config/config');
let configure = require('./app/helpers/configure');
let routes = require('./app/routes');
let log = require('./app/helpers/logger');
log.info('🔥 Firing up the KHE API');
// Make the app
let app = express();
let router = express.Router();
// Connect to database
let mongo = process.env.MONGO_URI || config.mongo.uri;
mongoose.connect(mongo);
// Initialize configuration
configure.app(app, router);
configure.seed();
// Start server
let port = process.env.PORT || config.port;
let server = app.listen(port);
let io = socketio(server);
log.info(`👂 Listening on port ${port}`);
// Export some useful objects
module.exports.app = app;
module.exports.router = router;
module.exports.io = io;
module.exports.projectRoot = __dirname;
// Include routes
routes(router);
log.info('😎 We are ready to go! Hack away.');