Created
May 18, 2013 17:50
-
-
Save geNAZt/5605267 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Fabian Faßbender | |
* @version 0.1.0 | |
* @file HTTP Module binds expressJS to HTTP NodeJS Servers | |
* @class HTTP | |
*/ | |
/** | |
* @requires module:express - NPM Install to get this | |
* @type {object} | |
*/ | |
var express = require('express'); | |
function HTTP($logger, $config) { | |
"use strict"; | |
//Start a Express App | |
var app = express(); | |
//Throw it into the Injector | |
Injector.use("$http", app); | |
$logger.debug("Starting HTTP Server(s)"); | |
//Start it on configured interfaces | |
var servers = []; | |
$config.get("./config.json").get("network").forEach(function(conn) { | |
servers.push(app.listen(conn.port, conn.ip, function() { | |
$logger.info("Listening on " + conn.ip + ":" + conn.port); | |
})); | |
}); | |
//Put all started servers into the Injector | |
Injector.use("$httpservers", servers); | |
} | |
(HTTP.inject())(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment