forked from zero-archive/node-url-shortener
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (25 loc) · 901 Bytes
/
app.js
File metadata and controls
30 lines (25 loc) · 901 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
var express = require('express')
, app = express()
, path = require('path')
, opts = require(path.join(__dirname, 'config', 'opts.js'))
, nus = require(path.join(__dirname, 'lib', 'nus.js'))(opts);
// Gotta Catch 'Em All
process.addListener('uncaughtException', function (err, stack) {
console.log('Caught exception: ' + err + '\n' + err.stack);
console.log('\u0007'); // Terminal bell
});
// Common options
app.set('__dirname', __dirname);
app.set('opts', opts);
app.set('x-powered-by', false);
// Load express configuration
require(path.join(__dirname, 'config', 'env.js'))(express, app);
// Load routes
require(path.join(__dirname, 'routes'))(app, nus);
// Start HTTP server
app.listen(opts.port, function () {
console.log('Express server listening on port %d in %s mode',
opts.port, app.settings.env
);
console.log('Running on %s (Press CTRL+C to quit)', opts.url);
});