shnapps
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,30 +0,23 @@ | ||
var Express = require('express'); | ||
var oneYear = 31557600000; | ||
var express = module.parent.require('express'); | ||
var parser = module.parent.require('./lib/uaparser'); | ||
var common = [ | ||
Express.logger({ format: ':date | :remote-addr | :method | :url | :status | :response-time' }), | ||
Express.bodyParser(), | ||
Express.methodOverride(), | ||
Express.cookieParser(), | ||
Express.session({secret:'SECRET_STRING'}) | ||
express.logger({ format: ':date | :remote-addr | :method | :url | :status | :response-time' }), | ||
express.bodyParser(), | ||
express.methodOverride(), | ||
express.cookieParser(), | ||
express.session({secret:'6e404410-2b6d-11e0-91fa-0800200c9a66'}), | ||
function(req, res, next) { | ||
req.ua = parser.parse(req.headers['user-agent'] || ''); | ||
next(); | ||
} | ||
]; | ||
module.exports = { | ||
development : { | ||
web : { | ||
docroot : '/ABSOLUTE/PATH/TO/DOCUMENT/ROOT', | ||
port : 8002, | ||
middleware : common.concat([ | ||
Express.errorHandler({dumpExceptions:true, showStack:true}) | ||
]) | ||
} | ||
}, | ||
production : { | ||
web : { | ||
docroot : '/ABSOLUTE/PATH/TO/DOCUMENT/ROOT', | ||
port : 8002, | ||
middleware : common.concat([ | ||
Express.errorHandler() | ||
]) | ||
} | ||
} | ||
}; | ||
web : { | ||
docroot : '/Users/blago/local/var/www', | ||
port : 8002, | ||
middleware : common.concat([ | ||
express.errorHandler({dumpExceptions:true, showStack:true}) | ||
]) | ||
} | ||
}; |
{ | ||
"name":"shnapps", | ||
"version":"0.1.0", | ||
"version":"0.1.1", | ||
"dependencies" : { | ||
@@ -5,0 +5,0 @@ "express" : "= 3.2.4", |
66
www.js
@@ -52,25 +52,27 @@ #!/usr/bin/env node | ||
var program = require('commander'); parseArguments(program); | ||
var config = require('./config')[program.environment]; | ||
var config = require(program.config); | ||
// add a cron job to start the server on reboot | ||
require('crontab').load(function cronLoaded(err, tab) { | ||
if (err) { | ||
console.error(err.message.red); | ||
process.exit(1); | ||
} | ||
if (program.startup == true) { | ||
require('crontab').load(function cronLoaded(err, tab) { | ||
if (err) { | ||
console.error(err.message.red); | ||
process.exit(1); | ||
} | ||
var uuid = '74d967a0-120b-11e0-ac64-0800200c9a66'; | ||
var nodePath = process.execPath.split('/').slice(0, -1).join('/'); | ||
var exptCommand = 'export PATH=' + nodePath + ':$PATH'; | ||
var options = ' -e ' + program.environment; | ||
var wwwCommand = __filename + options; | ||
var forevCommand = path.join(__dirname, 'node_modules', 'forever', 'bin', 'forever'); | ||
var sysCommand = exptCommand + ' && ' + forevCommand + ' start ' + wwwCommand; | ||
var uuid = '74d967a0-120b-11e0-ac64-0800200c9a66'; | ||
var nodePath = process.execPath.split('/').slice(0, -1).join('/'); | ||
var exptCommand = 'export PATH=' + nodePath + ':$PATH'; | ||
var options = ' -e ' + program.environment; | ||
var wwwCommand = __filename + options; | ||
var forevCommand = path.join(__dirname, 'node_modules', 'forever', 'bin', 'forever'); | ||
var sysCommand = exptCommand + ' && ' + forevCommand + ' start ' + wwwCommand; | ||
tab.remove(tab.findComment(uuid)); | ||
tab.remove(tab.findComment(uuid)); | ||
var item = tab.create(sysCommand, uuid); | ||
item.everyReboot(); | ||
tab.save(); | ||
}); | ||
var item = tab.create(sysCommand, uuid); | ||
item.everyReboot(); | ||
tab.save(); | ||
}); | ||
} | ||
@@ -153,5 +155,7 @@ var rest = express(); | ||
program | ||
.version('0.0.1') | ||
.version('0.1.0') | ||
.usage('[options]') | ||
.option('-e, --environment <name>', 'Environment', String, process.env.NODE_ENV) | ||
.option('-e, --environment <name>', 'string', String) | ||
.option('-c, --config <path>', 'string', String) | ||
.option('-s, --startup [flag]', 'true|false', true) | ||
.parse(process.argv); | ||
@@ -163,2 +167,24 @@ | ||
} | ||
if (!program.config) { | ||
console.error('No config file specified.'.red) | ||
process.exit(1); | ||
} | ||
var configFile = path.resolve(program.config); | ||
if (fs.existsSync(configFile) == false) { | ||
console.log('Config file doesn\'t exist: '.red, program.config); | ||
process.exit(1); | ||
} | ||
program.config = configFile; | ||
if (program.startup == 'true') { | ||
program.startup = true; | ||
} | ||
if (program.startup == 'false') { | ||
program.startup = false; | ||
} | ||
if (program.startup !== true && program.startup !== false) { | ||
console.error('Startup argument must be true or false.'.red) | ||
process.exit(1); | ||
} | ||
} | ||
@@ -165,0 +191,0 @@ |
Sorry, the diff of this file is not supported yet
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
135218
1127