Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: fgnass/nodester
base: 4c5cd69639
...
head fork: fgnass/nodester
compare: aacf2ff7f1
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
1  .app.pid.2
@@ -1 +0,0 @@
-18410
View
55 app.js
@@ -35,19 +35,24 @@ app.configure(function () {
/*
* status emitter
*/
+var dash;
-var bolt = require('bolt');
+function emit(hook, data) {
+ if (dash) dash.emit(hook, data);
+}
-var dash = new bolt.Node({
+if (config.opt.redis) {
+ var bolt = require('bolt');
+ dash = new bolt.Node({
delimiter : '::',
host : config.opt.redis.host,
port : config.opt.redis.port,
user : config.opt.redis.user,
auth : config.opt.redis.auth,
silent : true
-});
-
-dash.start();
+ });
+ dash.start();
+}
/*
* Error handler
@@ -58,7 +63,7 @@ app.error(function (err, req, res, next) {
res.sendfile(__dirname + '/public/404.html')
} else {
log.warn(err)
- dash.emit('nodester::500',{msg:err.message,stack:err.stack.toString()})
+ emit('nodester::500',{msg:err.message,stack:err.stack.toString()})
res.sendfile(__dirname + '/public/500.html')
}
});
@@ -75,7 +80,7 @@ app.all('*',function(req,res,next){
ua : req.headers['user-agent'] || 'nodester',
host : req.headers.host
}
- dash.emit('nodester::incomingRequest', toEmit)
+ emit('nodester::incomingRequest', toEmit)
}
next()
})
@@ -95,7 +100,7 @@ function getStats(){
* Ping every 3 seconds
*/
setInterval(function(){
- dash.emit('nodester::ping',{date:new Date})
+ emit('nodester::ping',{date:new Date})
},3000)
/*
@@ -103,12 +108,12 @@ setInterval(function(){
*/
setInterval(function(){
- dash.emit('nodester::stats',getStats())
+ emit('nodester::stats',getStats())
}, 5000)
process.on('uncaughtException', function (err) {
- dash.emit('nodester::uE',{ msg:err.message,stack:err.stack.toString()})
+ emit('nodester::uE',{ msg:err.message,stack:err.stack.toString()})
log.fatal(err.stack)
// Kill it with fire dude
var slog = fs.createWriteStream(path.join(config.opt.logs_dir + 'apperror.log'), {'flags': 'a'});
@@ -122,9 +127,9 @@ process.on('uncaughtException', function (err) {
/* Routes */
-/*
+/*
* Homepage Showcase
- *
+ *
*/
app.get('/', function (req, res, next) {
res.sendfile(__dirname +'/public/index.html')
@@ -155,8 +160,8 @@ var auth = middle.authenticate
, deprecated = middle.deprecated
;
-/*
- * Status endPoint
+/*
+ * Status endPoint
* @Public: true
* @HTTP method: http://api.host.com/status
* @raw: curl http://api.host.com/status
@@ -205,7 +210,7 @@ app.post('/user', user.post);
* Edit your user account
* @Public: false, only with authentication
* @raw: curl -X PUT -u "testuser:123" -d "password=test&rsakey=1234567" http://localhost:4001/user
- * @cli: nodester user
+ * @cli: nodester user
*/
app.put('/user', auth, user.put);
@@ -224,7 +229,7 @@ app.del('/user', auth, user.delete);
*/
var apps = require('./lib/apps');
-/*
+/*
* All Applications info
* @HTTP: http://chris:123@localhost:4001/apps
* @raw: curl -u "testuser:123" http://localhost:4001/apps
@@ -239,12 +244,12 @@ app.get('/apps', auth, apps.get);
var _app_ = require('./lib/app')
-/*
+/*
* Application info
* @HTTP: http://chris:123@localhost:4001/apps/<appname>
* @raw: curl -u "testuser:123" http://localhost:4001/apps/<appname>
* @cli: nodester app info <appname>
- */
+ */
app.get('/apps/:appname', auth, authApp, _app_.get);
app.get('/app/:appname', deprecated, auth, authApp, _app_.get); // deprecated
@@ -274,7 +279,7 @@ app.get('/app_stop', _app_.app_stop);
* @params start=initfile.js
* @params running=true|false (stop,start)
* Raw output:
- * curl -X PUT -u "testuser:123" -d "start=hello.js" http://localhost:4001/apps/test
+ * curl -X PUT -u "testuser:123" -d "start=hello.js" http://localhost:4001/apps/test
* curl -X PUT -u "testuser:123" -d "running=true" http://localhost:4001/apps/test
* curl -X PUT -u "testuser:123" -d "running=false" http://localhost:4001/apps/test
* curl -X PUT -u "testuser:123" -d "running=restart" http://localhost:4001/apps/test
@@ -306,13 +311,13 @@ app.del('/gitreset/:appname', auth, authApp, _app_.gitreset);
*/
app.get('/applogs/:appname', auth, authApp, _app_.logs);
-/*
+/*
* Retrieve information about or update a node app's ENV variables
* This fulfills all four RESTful verbs.
* @method: GET will retrieve the list of all keys.
* @method: PUT will either create or update.
* @method: DELETE will delete the key if it exists.
- * Raw output:
+ * Raw output:
* curl -u GET -u "testuser:123" -d "appname=test" http://localhost:4001/env
* curl -u PUT -u "testuser:123" -d "appname=test&key=NODE_ENV&value=production" http://localhost:4001/env
* curl -u DELETE -u "testuser:123" -d "appname=test&key=NODE_ENV" http://localhost:4001/env
@@ -338,14 +343,14 @@ app.del('/env/:appname/:key', auth, authApp, _app_.env_delete);
*/
var npm = require('./lib/npm');
-/*
+/*
* Install package
- * @raw:
+ * @raw:
* curl -X POST -u "testuser:123" -d "appname=test&package=express" http://localhost:4001/appnpm
* curl -X POST -u "testuser:123" -d "appname=test&package=express" http://localhost:4001/npm
* curl -X POST -u "testuser:123" -d "appname=test&package=express,express-extras,foo" http://localhost:4001/npm
*/
-
+
app.post('/appnpm', auth, authApp, npm.post);
app.post('/npm', auth, authApp, npm.post);
@@ -390,6 +395,6 @@ function NotFound(msg) {
};
// Globalization of log
-process.log = log
+process.log = log
/* End of file */
1  deps/nodemon
@@ -1 +0,0 @@
-Subproject commit 1738324cfa6abc37cbfeeee341eff0f88dbf28ca
View
33 example_config.js
@@ -1,3 +1,5 @@
+var HOME = '/var/nodester';
+
exports.opt = {
couch_user: 'nodester',
couch_pass: 'password',
@@ -5,18 +7,18 @@ exports.opt = {
couch_port: 5984,
couch_prefix: 'nodester',
couch_tables: ['coupons', 'nodefu', 'nextport', 'apps', 'repos', 'aliasdomains', 'password_resets', 'admins'],
- home_dir: '/var/nodester',
- app_dir: '/var/nodester/nodester',
+ home_dir: HOME,
+ app_dir: HOME + '/nodester',
git_home_dir: '/git',
apps_home_dir: '/app',
- public_html_dir: '/var/nodester/nodester/public',
- proxy_table_file: '/var/nodester/var/proxy_table.json',
+ public_html_dir: HOME + '/nodester/public',
+ proxy_table_file: HOME + '/var/proxy_table.json',
logs_dir: '/node/logs/',
tl_dom: 'testnodester.com',
api_dom: 'api.testnodester.com',
git_user: 'nodester',
git_dom: 'testnodester.com',
- coupon_code: 'CouponCode',
+ coupon_code: 'CouponCode', // Remove or set to a falsy value in order to disable coupon feature.
blocked_apps: ['www', 'api', 'admin', 'support', 'blog', 'site'],
restart_key: 'KeepThisSecret',
userid: 'nodester',
@@ -27,18 +29,25 @@ exports.opt = {
ssl_key_file: '',
node_base_folder: '/opt/node-v0.4.9_npm_v1.0.3',
+ // Uncomment this to emit status events via Redis pubsub
+ // see http://bolt.io
+ /*
redis: {
host: '127.0.0.1',
port: 6379,
user: 'nodester',
auth: 'password'
+ },
+ */
- },
-
- //Amazon SES mail info
- SES: {
- AWSAccessKeyID: 'ACCESSKEY',
- AWSSecretKey: 'SECRETKEY',
- ServiceUrl: 'https://email.us-east-1.amazonaws.com',
+ // Used by scripts/mailer.js to send password reset emails
+ mail: {
+ transport: 'SES', // see https://github.com/andris9/Nodemailer
+ config: {
+ AWSAccessKeyID: 'ACCESSKEY',
+ AWSSecretKey: 'SECRETKEY',
+ ServiceUrl: 'https://email.us-east-1.amazonaws.com',
+ }
}
+
};
View
8 lib/user.js
@@ -16,7 +16,7 @@ var config = require('../config')
var isValidKey = function (key) {
var decoded, type, _ref;
_ref = key.split(' '), type = _ref[0], key = _ref[1];
- if (!((type != null) && (key != null) && (type === 'ssh-rsa' || type === 'ssh-dss'))) {
+ if (!key || type != 'ssh-rsa' || type != 'ssh-dss') {
return false;
}
decoded = new Buffer(key, 'base64').toString('ascii');
@@ -28,7 +28,7 @@ var isValidKey = function (key) {
User.delete = function (req, res, next) {
-
+
var user = req.user
, db = lib.get_couchdb_database('nodefu');
@@ -68,7 +68,7 @@ User.put = function (req, res, next) {
status: "failure - invalid password. must be at least 1 character"
},400);
return true;
- }
+ }
if (user.match(/^[a-z0-9]+$/i) === null){
res.json({
status: "failure - invalid username. must be alphanumeric"
@@ -125,7 +125,7 @@ User.post = function (req, res, next) {
, rsakey = req.body.rsakey
;
- if (req.body.coupon == config.opt.coupon_code) {
+ if (!config.opt.coupon_code || req.body.coupon == config.opt.coupon_code) {
// validate passwords
if (newpass && newpass.length < 1) {
View
14 scripts/mailer.js
@@ -5,16 +5,22 @@ var mailer = require('nodemailer')
, config = require('../config')
;
-var resets = lib.get_couchdb_database('password_resets');
+var resets = lib.get_couchdb_database('password_resets')
+ , mailerOpts = config.opt.mail
-mailer.SES = config.opt.SES;
+if (config.opt.SES) mailerOpts = {
+ transport: 'SES',
+ opts: config.opt.SES
+}
+
+var transport = mailer.createTransport(mailerOpts.transport, mailerOpts.config)
function send_email(doc) {
- mailer.send_mail({
+ transport.sendMail({
sender : 'support@nodester.com',
to : doc.id,
subject : 'Password reset request',
- body : 'Here is your password request token: ' + doc.value.token + '\n\nYou can reset your password via Nodester API or CLI'
+ text : 'Here is your password request token: ' + doc.value.token + '\n\nYou can reset your password via Nodester API or CLI'
}, function (error, success) {
console.log(new Date,'Reset password e-mail sent to: ' + doc.id)
console.log(new Date, 'Message ' + success ? 'sent' : 'failed');

No commit comments for this range

Something went wrong with that request. Please try again.