Skip to content
This repository was archived by the owner on Feb 8, 2018. It is now read-only.

Commit e4b7313

Browse files
committed
make new jshint happy
1 parent f26e9c5 commit e4b7313

20 files changed

+78
-65
lines changed

.jshintrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"laxcomma" : "true"
2+
"laxcomma" : true
3+
, "node" : true
4+
, "curly" : false
35
}

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
"use strict";
2+
13
var app = require('./lib/express')
24
, http = require('http')
35
, https = require('https')
46
, fs = require('fs')
5-
, http_port = process.env.PORT_HTTP || process.env.PORT || 8080
6-
, https_port = process.env.PORT_HTTPS || 4430
77
;
88

9-
function listening() {
9+
var listening = function listening() {
1010
var addr = this.address();
1111
var type = this.hasOwnProperty('key') ? 'https' : 'http';
1212
console.log('* listening on %s://%s:%d', type, addr.address, addr.port);
13-
}
13+
};
1414

1515
function startHttp() {
1616
var port = process.env.npm_package_config_http_port;

lib/express.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
"use strict";
2+
13
var express = require('express')
24
, app = express()
35
, routes = require('../routes')
46
, ormloader = require('../models')
57
, ratelimit = require('../lib/ratelimit.js')
8+
, paging = require('../lib/paging.js')
69
;
710
module.exports = app;
811

@@ -18,16 +21,7 @@ app.configure(function(){
1821
app.use(ratelimit());
1922
app.use(express.favicon());
2023
app.use(ormloader());
21-
22-
23-
app.use(function(req, res, next){
24-
req.page = {
25-
limit : Math.min( +req.query.limit || 25 , 200 )
26-
, offset : +req.query.offset || 0
27-
};
28-
return next();
29-
});
30-
24+
app.use(paging());
3125
});
3226

3327
routes(app);

lib/hal.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
"use strict";
12

2-
function addHAL(type, name, obj, force_array) {
3+
var addHAL = function addHAL(type, name, obj, force_array) {
34
if (! this.hasOwnProperty(type) )
45
this[type] = {};
56

@@ -13,7 +14,7 @@ function addHAL(type, name, obj, force_array) {
1314
}
1415

1516
return this;
16-
}
17+
};
1718

1819

1920
module.exports = {

lib/paging.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use strict";
2+
3+
function sorter(a, b){
4+
return (a - b);
5+
}
6+
7+
function gate(val, def, min, max) {
8+
var vals = [ +val || def ];
9+
10+
if ('undefined' !== typeof min)
11+
vals.push(min);
12+
if ('undefined' !== typeof max)
13+
vals.push(max);
14+
15+
if (vals.length < 2)
16+
return def;
17+
18+
return (vals.sort(sorter))[1];
19+
}
20+
21+
module.exports = function(key) {
22+
key = key || 'page';
23+
24+
return function(req, res, next) {
25+
req[key] = {
26+
limit : gate(req.query.limit, 25, 1, 200)
27+
, offset : gate(req.query.offset, 0)
28+
};
29+
return next();
30+
};
31+
};

lib/ratelimit.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
var limiter = require('connect-ratelimit');
24

35
var default_conf = {

migrations/20130613000000-install-hstore.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
module.exports.up = function(db, cb) {
24
db.runSql('create extension if not exists hstore', cb);
35
};

migrations/20130613213125-init.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var dbm = require('db-migrate');
1+
"use strict";
2+
23
var here = require('here').here;
34
var async = require('async');
45

migrations/20130629121557-add-geodata.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict";
12

23
exports.up = function(db, callback) {
34
/* if location == null, it's an anon. node we have no info about yet */

migrations/20130727090718-node-upload-return-ids.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
var here = require('here').here;
24

35
exports.up = function(db, cb) {

models/Measurement.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
var hooks = require('./hooks.js');
24

35
module.exports = function(db, cb){

models/Node.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
function lonlat(field) {
24
return function(val) {
35
if (val !== undefined) {
@@ -8,7 +10,7 @@ function lonlat(field) {
810
}
911

1012
module.exports = function(db, cb){
11-
var Node = db.define('Node', {
13+
db.define('Node', {
1214
name : { type: 'text', required: true }
1315
, owner : { type: 'text', required: true }
1416
, location : { type: 'point', required: false }

models/NodeUpload.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
"use strict";
2+
13
var hooks = require('./hooks.js');
24

35
module.exports = function(db, cb){
4-
var NodeUpload = db.define('NodeUpload', {
6+
db.define('NodeUpload', {
57
node_name : { type: 'text', required: true }
68
, ts : { type: 'date', required: true }
79
, data : { type: 'binary', required: true }

models/Upload.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
module.exports = function(db, cb){
24
var Upload = db.define('Upload', {
35
ts : { type: 'date', required: true }

models/hooks.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
"use strict";
2+
13
var hstore = require('pg-hstore');
24

35
function hstore2json(field) {
46
return function() {
57
if (typeof this[field] === 'string')
6-
this[field]= hstore.parse(this[field]);
8+
this[field] = hstore.parse(this[field]);
79
};
810
}
911

models/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
var orm = require('orm')
24
, transaction = require("orm-transaction")
35
, async = require('async')

routes/index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
"use strict";
2+
13
var Payload = require('dustmap-payload')
24
, async = require('async')
3-
, util = require('util')
45
, HAL = require('../lib/hal.js')
56
;
67

@@ -42,7 +43,7 @@ module.exports = function(app) {
4243
}
4344

4445
async.each(models_to_save, function(obj, cb){
45-
return obj.save(function(err, data){
46+
return obj.save(function(err){
4647
return cb( err ? err : null );
4748
});
4849
}, function(err){
@@ -196,7 +197,8 @@ module.exports = function(app) {
196197
async.each(uploads, handleUpload, function(err){
197198
if (err)
198199
res.send(400, err);
199-
res.send(node);
200+
201+
res.send(node);
200202
});
201203
});
202204
});

test/integration_tests/BEGIN.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
var util = require('util');
24
var exec = require('child_process').exec;
35
var path = require('path');

test/integration_tests/webapp.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
"use strict";
2+
13
var app = require('../../lib/express.js')
24
, request = require('supertest')(app)
3-
, async = require('async')
45
;
56

67

test/run.sh

-40
This file was deleted.

0 commit comments

Comments
 (0)