-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
41 lines (32 loc) · 993 Bytes
/
Copy pathserver.js
File metadata and controls
41 lines (32 loc) · 993 Bytes
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
// Global Variables
var env = require('node-env-file')
env(__dirname + '/.environment/public.env')
env(__dirname + '/.environment/private.env')
// Global Dependencies
var express = require('express')
var colors = require('colors')
// Configuration
var config = require('./configuration')()
var routes = require('./configuration/routes')
// Initialize Server
var app = express()
// Configure Middleware
config.middleware(app)
// Initialize Routes
routes(app)
// Execute Server
var server = app.listen(config.settings.port, function() {
console.log('Listening on port ' + config.settings.port.blue + ' in a ' + process.env.NODE_ENV.blue + ' environment.')
}).on('error', function(e) {
if (e.code == 'EADDRINUSE') {
console.log('Address in use. Is the server already running?'.red)
}
})
// For Testing
server.endpoints = app._router.stack.filter(function(r) {
if (r.route && r.route.path) {
return r.route.path
}
return
})
module.exports = server