Comparing version 0.6.0 to 0.6.1
# History | ||
## 0.6.1 | ||
- Bumped the default recursion limit to 2 levels | ||
- Fixed rare case where a resource's dashboard would not load | ||
- Fixed user events | ||
- Fixed several validation bugs | ||
- In a UserCollection /users/me will return 204 instead of 401 | ||
## 0.6.0 | ||
@@ -4,0 +12,0 @@ |
@@ -85,3 +85,2 @@ var fs = require('fs') | ||
resource = new types[o.config.type](name, o); | ||
resources.push(resource); | ||
if (resource.load) { | ||
@@ -91,5 +90,11 @@ remaining++; | ||
remaining--; | ||
if (err) error = err; | ||
if (err) { | ||
error = err; | ||
return done(); | ||
} | ||
resources.push(resource); | ||
done(); | ||
}); | ||
} else { | ||
resources.push(resource); | ||
} | ||
@@ -96,0 +101,0 @@ } catch(e) { |
@@ -40,2 +40,8 @@ var internalClient = require('./internal-client') | ||
if ((this.query && typeof this.query.$limitRecursion !== 'undefined') || (this.body && typeof this.body.$limitRecursion !== 'undefined')) { | ||
var recursionLimit = this.query.$limitRecursion || this.body.$limitRecursion || 0; | ||
req.stack = req.stack || []; | ||
req.stack.recursionLimit = recursionLimit; | ||
} | ||
this.dpd = internalClient.build(server, req.session, req.stack); | ||
@@ -42,0 +48,0 @@ } |
@@ -66,3 +66,5 @@ var debug = require('debug')('internal-client'); | ||
, res | ||
, urlKey; | ||
, urlKey | ||
, recursions | ||
, recursionLimit; | ||
@@ -80,7 +82,10 @@ req = { | ||
req.stack = stack || []; | ||
debug("Stack: %j", stack); | ||
if (req.stack.indexOf(urlKey) === -1) { | ||
recursions = req.stack.filter(function(s) { return s === urlKey; }).length; | ||
recursionLimit = (stack && stack.recursionLimit) || 2; | ||
if (recursions < recursionLimit) { | ||
req.stack.push(urlKey); | ||
@@ -87,0 +92,0 @@ debug("Putting %s on stack", urlKey); |
@@ -144,2 +144,5 @@ var validation = require('validation') | ||
if(!prop && key.indexOf('$') !== 0 && key !== 'id') return; | ||
// hack - $limitRecursion is not a mongo property so we'll get rid of it, too | ||
if (key === '$limitRecursion') return; | ||
@@ -420,3 +423,3 @@ if(expected == 'number' && actual == 'string') { | ||
if(errs) return done(errs); | ||
if(errs) return done({errors: errs}); | ||
@@ -450,3 +453,3 @@ function commit(err) { | ||
if(errs) return done(errs); | ||
if(errs) return done({errors: errs}); | ||
@@ -453,0 +456,0 @@ // generate id before event listener |
@@ -83,3 +83,3 @@ var util = require('util') | ||
resourceId = parts[0]; | ||
resource = ctx.server.resources.filter(function(r) { return r.path === '/' + resourceId.toLowerCase() })[0]; | ||
resource = ctx.server.resources.filter(function(r) { return r.name === resourceId.toLowerCase() })[0]; | ||
@@ -107,3 +107,8 @@ if (resource) { | ||
resourceType = resource.constructor; | ||
debug("Editing resource %s of type %s", resourceId, resourceType.name); | ||
if (resourceType.dashboard) { | ||
@@ -110,0 +115,0 @@ |
@@ -41,2 +41,3 @@ var validation = require('validation') | ||
UserCollection.dashboard = Collection.dashboard; | ||
UserCollection.events = Collection.events; | ||
@@ -62,3 +63,3 @@ /** | ||
// set id one wasnt provided in the query | ||
ctx.query.id = ctx.query.id || this.parseId(ctx); | ||
ctx.query.id = ctx.query.id || this.parseId(ctx) || (ctx.body && ctx.body.id); | ||
@@ -74,4 +75,4 @@ // make sure password will never be included | ||
if(!(ctx.session && ctx.session.data && ctx.session.data.uid)) { | ||
ctx.res.statusCode = 401; | ||
return ctx.done('Not logged in'); | ||
ctx.res.statusCode = 204; | ||
return ctx.done(); | ||
} | ||
@@ -123,3 +124,3 @@ | ||
if(ctx.query.id) { | ||
if(ctx.query.id || ctx.body.id) { | ||
this.save(ctx, done); | ||
@@ -126,0 +127,0 @@ } else { |
@@ -148,4 +148,11 @@ var http = require('http') | ||
config.loadConfig('./', server, function(err, resourcesInstances) { | ||
server.resources = resourcesInstances; | ||
http.Server.prototype.listen.call(server, port || server.options.port, host || server.options.host); | ||
if (err) { | ||
console.log("Error loading resources: "); | ||
console.log(err.stack); | ||
process.exit(); | ||
} else { | ||
server.resources = resourcesInstances; | ||
http.Server.prototype.listen.call(server, port || server.options.port, host || server.options.host); | ||
} | ||
}); | ||
@@ -152,0 +159,0 @@ return this; |
{ | ||
"author": "Ritchie Martori", | ||
"name": "deployd", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "url": "git://github.com/deployd/deployd.git" |
@@ -82,2 +82,12 @@ describe('Collection', function() { | ||
describe('.post({}, fn)', function() { | ||
it('should return a validation error', function(done) { | ||
dpd.todos.post({}, function(res, err) { | ||
expect(err).to.exist; | ||
expect(err.errors.title).to.be.ok; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('.post({message: "notvalid"}, fn)', function() { | ||
@@ -94,7 +104,7 @@ it('should properly return an error', function(done) { | ||
describe('.post({title: 7}, fn)', function() { | ||
it('should sanitize the title due to incorrect type', function(done) { | ||
dpd.todos.post({title: 7}, function (todo, err) { | ||
describe('.post({title: "foo", owner: 7}, fn)', function() { | ||
it('should sanitize the owner due to incorrect type', function(done) { | ||
dpd.todos.post({title: "foo", owner: 7}, function (todo, err) { | ||
delete todo.id; | ||
expect(todo).to.eql({done: false}); | ||
expect(todo).to.eql({title: "foo", done: false}); | ||
done() | ||
@@ -384,3 +394,3 @@ }) | ||
it('should only go one level deep', function(done) { | ||
it('should only go two levels deep', function(done) { | ||
this.timeout(1000); | ||
@@ -393,4 +403,6 @@ dpd.recursive.get(function(result, err) { | ||
expect(obj.more).to.exist; | ||
expect(obj.more.length).to.equal(1); | ||
expect(obj.more[0].more).to.not.be.ok; | ||
expect(obj.more[0]).to.exist; | ||
expect(obj.more[0].more).to.exist; | ||
expect(obj.more[0].more[0]).to.exist; | ||
expect(obj.more[0].more[0].more).to.not.exist; | ||
done(err); | ||
@@ -400,2 +412,21 @@ }); | ||
it('should be customizable', function(done) { | ||
this.timeout(1000); | ||
dpd.recursive.get({$limitRecursion: 10}, function(result, err) { | ||
var obj = result[0]; | ||
expect(result.length).to.equal(1); | ||
expect(obj).to.exist; | ||
expect(obj.more).to.exist; | ||
var current = obj.more[0]; | ||
for (var i = 0; i < 9; i++) { | ||
expect(current).to.exist; | ||
expect(current.more).to.exist; | ||
current = current.more[0]; | ||
}; | ||
expect(current.more).to.not.exist; | ||
done(err); | ||
}); | ||
}); | ||
afterEach(function (done) { | ||
@@ -402,0 +433,0 @@ this.timeout(10000); |
@@ -32,2 +32,31 @@ var credentials = { | ||
}); | ||
it('should properly show username and password errors', function(done) { | ||
dpd.users.post({}, function(res, err) { | ||
expect(res).to.not.exist; | ||
expect(err.errors.username).to.be.ok; | ||
expect(err.errors.password).to.be.ok; | ||
done(); | ||
}); | ||
}); | ||
it('should update if id is passed in the body', function(done) { | ||
chain(function(next) { | ||
dpd.users.post({username: 'foo', password: 'bar'}, next); | ||
}).chain(function(next, res, err) { | ||
dpd.users.post({id: res.id, username: 'test'}, next); | ||
}).chain(function(next, res, err) { | ||
done(err); | ||
}) | ||
}); | ||
it('should update if id is passed in the url', function(done) { | ||
chain(function(next) { | ||
dpd.users.post({username: 'foo', password: 'bar'}, next); | ||
}).chain(function(next, res, err) { | ||
dpd.users.post(res.id, {username: 'test'}, next); | ||
}).chain(function(next, res, err) { | ||
done(err); | ||
}) | ||
}); | ||
}) | ||
@@ -45,2 +74,9 @@ describe('.login(credentials, fn)', function() { | ||
}) | ||
it('should not crash the server when called without a body', function(done) { | ||
dpd.users.login(null, function(session, err) { | ||
expect(err).to.exist; | ||
done(); | ||
}); | ||
}); | ||
}) | ||
@@ -84,8 +120,8 @@ describe('.me(fn)', function() { | ||
it('should respond to the built-in changed event on put', function(done) { | ||
dpd.todos.post({username: 'foo2@bar.com', password: '123456'}, function(item) { | ||
dpd.todos.on('changed', function() { | ||
dpd.users.post({username: 'foo2@bar.com', password: '123456'}, function(item) { | ||
dpd.users.on('changed', function() { | ||
done(); | ||
}); | ||
dpd.todos.put(item.id, {username: 'foo3@bar.com'}); | ||
dpd.users.put(item.id, {username: 'foo3@bar.com'}); | ||
}); | ||
@@ -95,11 +131,23 @@ }) | ||
it('should respond to the built-in changed event on del', function(done) { | ||
dpd.todos.post({title: 'changed - create'}, function(item) { | ||
dpd.todos.on('changed', function() { | ||
dpd.users.post({username: 'foo2@bar.com', password: '123456'}, function(item) { | ||
dpd.users.on('changed', function() { | ||
done(); | ||
}); | ||
dpd.todos.del(item.id); | ||
dpd.users.del(item.id); | ||
}); | ||
}) | ||
}) | ||
describe('dpd.users.put({}, fn)', function() { | ||
it('should allow omitting username and password', function(done) { | ||
chain(function(next) { | ||
dpd.users.post({username: 'foo', password: 'bar'}, next); | ||
}).chain(function(next, res, err) { | ||
dpd.users.put(res.id, {username: 'test'}, next); | ||
}).chain(function(next, res, err) { | ||
done(err); | ||
}) | ||
}); | ||
}); | ||
}) | ||
@@ -106,0 +154,0 @@ |
@@ -31,3 +31,3 @@ { | ||
"type": "number", | ||
"typeLabel": "string", | ||
"typeLabel": "number", | ||
"id": "order", | ||
@@ -47,3 +47,3 @@ "name": "order", | ||
"title": { | ||
"required": false, | ||
"required": true, | ||
"type": "string", | ||
@@ -50,0 +50,0 @@ "typeLabel": "string", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
37563
38
2100721
205