-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (22 loc) · 784 Bytes
/
server.js
File metadata and controls
28 lines (22 loc) · 784 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
'use strict';
var http = require('http');
global.CORE_PATH = __dirname;
require('./config/path.js');
function Server(serverConfiguration) {
var config = _completeConfig(serverConfiguration);
this.start = function (requestListener) {
var server = http.createServer(requestListener);
server.listen.call(server, config.port, config.hostname);
console.log('Start server ' + config.name + ' on ' + config.hostname + ':' + config.port);
};
return this;
function _completeConfig(config) {
if (!config.port) {
throw new Error('You need to define a port in your application.js config file');
}
if (!config.hostname) config.hostname = '127.0.0.1';
if (!config.name) config.name = 'My Project ';
return config;
}
}
module.exports = Server;