mixdown-server
Advanced tools
Comparing version 0.2.4 to 0.3.3
@@ -7,3 +7,4 @@ var mixdown = {}; | ||
mixdown.Logger = require('./lib/logger'); | ||
mixdown.MainFactory = require('./lib/main'); | ||
module.exports = mixdown; |
@@ -34,3 +34,2 @@ var util = require('util'), | ||
if (path) { | ||
try { | ||
@@ -37,0 +36,0 @@ Mod = require(path); |
var _ = require('lodash'), | ||
winston = require('winston'), | ||
syslog = require('winston-syslog'); | ||
winston = require('winston'); | ||
require('winston-syslog'); | ||
// Until this is fixed, attaching to global logger seems to be only option. | ||
// https://github.com/indexzero/winston-syslog/issues/7 | ||
module.exports.create = function(options) { | ||
var logger = null; | ||
var logger = winston; | ||
if (options) { | ||
if (options) { | ||
// create array of transports from config. | ||
var transports = _.map(options.transports, function(transport) { | ||
// create array of transports from config. | ||
var transports = _.map(options.transports, function(transport) { | ||
var opt = _.defaults(transport.options, options.defaults); | ||
logger.add(winston.transports[transport.transport], opt); | ||
}); | ||
var opt = _.defaults(transport.options, options.defaults); | ||
return new (winston.transports[transport.transport])({ | ||
handleExceptions: opt.handleExceptions, | ||
json: opt.json, | ||
timestamp: opt.timestamp, | ||
colorize: opt.colorize | ||
}); | ||
}); | ||
// set levels | ||
logger.setLevels(winston.config.syslog.levels); | ||
} | ||
// create logger instance | ||
logger = new (winston.Logger)({ | ||
exitOnError: false, | ||
transports: transports | ||
}); | ||
// set levels | ||
logger.setLevels(winston.config.syslog.levels); | ||
} | ||
return logger; | ||
return logger; | ||
}; |
var _ = require('lodash'), | ||
http = require('http'); | ||
fs = require('fs'), | ||
http = require('http'), | ||
cluster = require('cluster'); | ||
@@ -24,23 +26,23 @@ module.exports = function(serverConfig) { | ||
try { | ||
// Create the main server | ||
var vhosts = {}; | ||
// Create the main server | ||
var vhosts = {}; | ||
// Loop over cobrands and add all of the apps by hostnames so that express can do the mapping automatically. | ||
_.each(serverConfig.apps, function(app) { | ||
// Loop over cobrands and add all of the apps by hostnames so that express can do the mapping automatically. | ||
_.each(serverConfig.apps, function(app) { | ||
// logger.info(siteConfig.hostmap); | ||
// consider moving the logger stuff to event emitters | ||
// logger.info(siteConfig.hostmap); | ||
// consider moving the logger stuff to event emitters | ||
_.each(app.config.hostmap, function(host) { | ||
vhosts[host] = app; | ||
}); | ||
_.each(app.config.hostmap, function(host) { | ||
vhosts[host] = app; | ||
}); | ||
}); | ||
// Set port from server config. | ||
var port = serverConfig.server.port || 8080; | ||
// Set port from server config. | ||
var listen = serverConfig.server.listen || {}, | ||
lp = listen.type === 'unix' ? listen.path : listen.port; | ||
http.createServer(function (req, res) { | ||
var create = function() { | ||
var socket = http.createServer(function (req, res) { | ||
var host = req.headers.host.replace(/:\d+/, ''), | ||
@@ -57,10 +59,14 @@ app = vhosts[host]; | ||
}).listen(port); | ||
}).listen(lp, function(err) { | ||
callback(err, { socket: socket }); | ||
}); | ||
}; | ||
// remove old file descriptor if needed. | ||
if (listen.type === 'unix') { | ||
fs.unlink(lp, create); | ||
} | ||
catch (err) { | ||
callback(err); | ||
return; | ||
else { | ||
create(); | ||
} | ||
callback(); | ||
}; | ||
@@ -67,0 +73,0 @@ }; |
{ | ||
"name": "mixdown-server", | ||
"version": "0.2.4", | ||
"version": "0.3.3", | ||
"main": "index", | ||
@@ -28,7 +28,8 @@ "description": "Simple server for activiting a site.", | ||
"scripts": { | ||
"test": "node tests/example.js" | ||
"test": "node tests/main.js" | ||
}, | ||
"dependencies": { | ||
"lodash": "0.9.1", | ||
"lodash": "0.10.0", | ||
"broadway": "0.2.5", | ||
"optimist": "0.3.4", | ||
"winston": "0.6.2", | ||
@@ -35,0 +36,0 @@ "winston-syslog": "0.2.2" |
var _ = require('lodash'), | ||
VastLogger = require('../lib/logger'), | ||
mixdownLogger = require('../lib/logger'), | ||
tap = require('tap'), | ||
test = tap.test; | ||
global.logger = VastLogger.create({ | ||
global.logger = mixdownLogger.create({ | ||
"defaults": { | ||
@@ -8,0 +8,0 @@ "handleExceptions": false, |
@@ -43,4 +43,24 @@ { | ||
"server": { | ||
"port": 8080 | ||
"listen": { | ||
"port": "8080" | ||
}, | ||
"cluster": { | ||
"on": true, | ||
"workers": 2 | ||
}, | ||
"logger": { | ||
"defaults": { | ||
"handleExceptions": false, | ||
"json": false, | ||
"timestamp": true, | ||
"colorize": true | ||
}, | ||
"transports": [{ | ||
"transport": "Console", | ||
"options": { | ||
"handleExceptions": true | ||
} | ||
}] | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22999
23
731
5
7
3
+ Addedoptimist@0.3.4
+ Addedlodash@0.10.0(transitive)
+ Addedoptimist@0.3.4(transitive)
- Removedlodash@0.9.1(transitive)
- Removedoptimist@0.3.7(transitive)
Updatedlodash@0.10.0