Skip to content

Instantly share code, notes, and snippets.

@geNAZt
Created May 18, 2013 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geNAZt/5605267 to your computer and use it in GitHub Desktop.
Save geNAZt/5605267 to your computer and use it in GitHub Desktop.
/**
* @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