-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
45 lines (34 loc) · 1.04 KB
/
server.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
'use strict';
var _ = require('underscore');
var morgan = require('morgan');
var express = require('express');
var engines = require('consolidate');
var Server = function (options) {
this.options = options || {};
this.appName = options.appName || 'app';
this.port = options.port || process.env.PORT || 3031;
this.app = express();
this.configureServer();
this.configureRouting();
this.run();
};
_.extend(Server.prototype, {
configureServer: function () {
var app = this.app;
app.use(morgan());
app.use(express.static(__dirname + this.options.publicDir));
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
app.engine('html', engines.handlebars);
app.locals.title = 'iframessemarfi';
},
configureRouting: function () {
this.options.routing(this.app);
},
run: function () {
this.server = this.app.listen(this.port, function() {
console.log('%s is listening on port %d', this.appName, this.server.address().port);
}.bind(this));
}
});
module.exports = Server;