lint cleanup

This commit is contained in:
Josh Harvey 2014-11-20 23:06:14 -05:00
parent e12238c4fe
commit 2c756e231a
8 changed files with 20 additions and 21 deletions

View file

@ -28,6 +28,7 @@ if (!argv.http) {
options.mock = argv.mock; options.mock = argv.mock;
var server = createServer(options); var server = createServer(options);
server.listen(port, function () { server.listen(port, function() {
console.log('lamassu-server listening on port ' + port + ' ' + (argv.http ? '(http)' : '(https)')); console.log('lamassu-server listening on port ' + port + ' ' +
(argv.http ? '(http)' : '(https)'));
}); });

View file

@ -9,7 +9,7 @@ var plugins = require('./plugins');
var db = require('./postgresql_interface'); var db = require('./postgresql_interface');
var logger = require('./logger'); var logger = require('./logger');
module.exports = function (options) { module.exports = function(options) {
var app = express(); var app = express();
var connectionString; var connectionString;
var server; var server;
@ -23,7 +23,7 @@ module.exports = function (options) {
db.init(connectionString); db.init(connectionString);
plugins.init(db); plugins.init(db);
lamassuConfig.load(function (err, config) { lamassuConfig.load(function(err, config) {
if (err) { if (err) {
logger.error('Loading config failed'); logger.error('Loading config failed');
throw err; throw err;
@ -33,8 +33,8 @@ module.exports = function (options) {
plugins.startPolling(); plugins.startPolling();
}); });
lamassuConfig.on('configUpdate', function () { lamassuConfig.on('configUpdate', function() {
lamassuConfig.load(function (err, config) { lamassuConfig.load(function(err, config) {
if (err) { if (err) {
return logger.error('Error while reloading config'); return logger.error('Error while reloading config');
} }
@ -61,7 +61,8 @@ module.exports = function (options) {
server = https.createServer(serverOptions, app); server = https.createServer(serverOptions, app);
authMiddleware = function(req, res, next) { authMiddleware = function(req, res, next) {
lamassuConfig.isAuthorized(routes.getFingerprint(req), function (err, device) { lamassuConfig.isAuthorized(routes.getFingerprint(req), function(err,
device) {
if (err) { if (err) {
res.json({err: 'Internal Server Error'}); res.json({err: 'Internal Server Error'});
return next(err); return next(err);
@ -77,7 +78,7 @@ module.exports = function (options) {
} else { } else {
server = http.createServer(app); server = http.createServer(app);
authMiddleware = function (req, res, next) { authMiddleware = function(req, res, next) {
req.device = {}; req.device = {};
return next(); return next();
}; };

View file

@ -9,12 +9,10 @@ var logLevel = process.env.LAMASSU_ENV === 'debug' ?
var bunyan = bunyan.createLogger({name: 'lamassu-server', level: logLevel}); var bunyan = bunyan.createLogger({name: 'lamassu-server', level: logLevel});
// log version // log version
var version = require('../package.json').version; var version = require('../package.json').version;
bunyan.info('Version: %s', version); bunyan.info('Version: %s', version);
// log git stuff (optional) // log git stuff (optional)
// `git-rev` omits `err` param in callback, without this wrapper // `git-rev` omits `err` param in callback, without this wrapper
// `async` interprets returned values as errors. // `async` interprets returned values as errors.
@ -33,7 +31,6 @@ try {
function(err, values) { function(err, values) {
bunyan.info('Git: #%s @%s', values[0], values[1]); bunyan.info('Git: #%s @%s', values[0], values[1]);
}); });
} catch(_) {} } catch (_) {}
module.exports = bunyan; module.exports = bunyan;

View file

@ -21,7 +21,7 @@ var STALE_BALANCE = 180000;
var cartridges = null; var cartridges = null;
try { try {
cartridges = JSON.parse(fs.readFileSync('./cartridges.json')); cartridges = JSON.parse(fs.readFileSync('./cartridges.json'));
} catch(ex) { } catch (ex) {
logger.warn('No cartridges.json file found: ' + ex.message); logger.warn('No cartridges.json file found: ' + ex.message);
} }

View file

@ -2,7 +2,7 @@
var db = require('./db'); var db = require('./db');
exports.up = function(next){ exports.up = function(next) {
var sqls = [ var sqls = [
'CREATE TABLE IF NOT EXISTS user_config ( ' + 'CREATE TABLE IF NOT EXISTS user_config ( ' +
@ -50,6 +50,6 @@ exports.up = function(next){
db.multi(sqls, next); db.multi(sqls, next);
}; };
exports.down = function(next){ exports.down = function(next) {
next(); next();
}; };

View file

@ -2,7 +2,7 @@
var db = require('./db'); var db = require('./db');
exports.up = function(next){ exports.up = function(next) {
db.query('CREATE TABLE bills ( ' + db.query('CREATE TABLE bills ( ' +
'id uuid PRIMARY KEY, ' + 'id uuid PRIMARY KEY, ' +
'device_fingerprint text NOT NULL, ' + 'device_fingerprint text NOT NULL, ' +
@ -15,6 +15,6 @@ exports.up = function(next){
'created timestamp NOT NULL DEFAULT now() )', next); 'created timestamp NOT NULL DEFAULT now() )', next);
}; };
exports.down = function(next){ exports.down = function(next) {
next(); next();
}; };

View file

@ -2,7 +2,7 @@
var db = require('./db'); var db = require('./db');
exports.up = function(next){ exports.up = function(next) {
db.query('CREATE TABLE machine_events ( ' + db.query('CREATE TABLE machine_events ( ' +
'id uuid PRIMARY KEY, ' + 'id uuid PRIMARY KEY, ' +
'device_fingerprint text NOT NULL, ' + 'device_fingerprint text NOT NULL, ' +
@ -12,6 +12,6 @@ exports.up = function(next){
'created timestamp NOT NULL DEFAULT now() )', next); 'created timestamp NOT NULL DEFAULT now() )', next);
}; };
exports.down = function(next){ exports.down = function(next) {
next(); next();
}; };

View file

@ -4,7 +4,7 @@ var db = require('./db');
function singleQuotify(item) { return '\'' + item + '\''; } function singleQuotify(item) { return '\'' + item + '\''; }
exports.up = function(next){ exports.up = function(next) {
var stages = ['initial_request', 'partial_request', 'final_request', var stages = ['initial_request', 'partial_request', 'final_request',
'partial_send', 'deposit', 'dispense_request', 'dispense']. 'partial_send', 'deposit', 'dispense_request', 'dispense'].
map(singleQuotify).join(','); map(singleQuotify).join(',');
@ -61,6 +61,6 @@ exports.up = function(next){
db.multi(sqls, next); db.multi(sqls, next);
}; };
exports.down = function(next){ exports.down = function(next) {
next(); next();
}; };