Comparing version 0.5.1 to 0.5.2
@@ -26,3 +26,3 @@ var middleware = module.exports = { | ||
} | ||
query.select(request.select); | ||
query.select(request.query.select); | ||
} | ||
@@ -29,0 +29,0 @@ if (request.query.populate) { |
{ | ||
"name": "baucis", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
baucis v0.5.1 | ||
baucis v0.5.2 | ||
============= | ||
@@ -96,3 +96,3 @@ | ||
`bacuis.rest` | ||
`baucis.rest` | ||
------------- | ||
@@ -111,4 +111,13 @@ | ||
// Add middleware before API routes | ||
controller.use(function () { ... }); | ||
controller.use('/qux', function (request, response, next) { | ||
// Do something cool… | ||
next(); | ||
}); | ||
controller.get('/readme', function (request, response, next) { | ||
// Send a readme document about the resource (for example) | ||
next(); | ||
}); | ||
// Do other stuff... | ||
@@ -130,3 +139,3 @@ controller.set('some option name', 'value'); | ||
| request | This stage of middleware will be called after baucis applies defaults based on the request, but before the Mongoose query is generated | | ||
| query | This stage of middleware will be called after baucis applies defaults to the Mongoose query object, but before the documents or count is retrieved from the database. The query can be accessed in your custom middleware via `request.baucis.query`. | | ||
| query | This stage of middleware will be called after baucis applies defaults to the Mongoose query object, but before the documents or count are retrieved from the database. The query can be accessed in your custom middleware via `request.baucis.query`. | | ||
| documents | This stage of middleware will be called after baucis executes the query, but before the documents or count are sent in the response. The documents/count can be accessed in your custom middleware via `request.baucis.documents`. | | ||
@@ -206,8 +215,2 @@ | ||
// Embed arbitrary middleware at /foos/qux | ||
controller.use('/qux', function (request, response, next) { | ||
// Do something cool… | ||
next(); | ||
}); | ||
Contact | ||
@@ -214,0 +217,0 @@ ------- |
@@ -31,3 +31,3 @@ var expect = require('expect.js'); | ||
it('should set Last-Modified on save', function (done) { | ||
it('should save new lastModified date', function (done) { | ||
var vege = vegetables[0]; | ||
@@ -34,0 +34,0 @@ var originalModified = vege.get('lastModified'); |
@@ -80,2 +80,30 @@ var expect = require('expect.js'); | ||
it('should disallow using +fields with select', function (done) { | ||
var options = { | ||
url: 'http://localhost:8012/api/v1/vegetables?select=%2Bfoo', | ||
json: true | ||
}; | ||
request.get(options, function (err, response, body) { | ||
if (err) return done(err); | ||
expect(response).to.have.property('statusCode', 500); | ||
done(); | ||
}); | ||
}); | ||
it('should allow selecting fields', function (done) { | ||
var options = { | ||
url: 'http://localhost:8012/api/v1/vegetables?select=-_id lastModified', | ||
json: true | ||
}; | ||
request.get(options, function (err, response, body) { | ||
if (err) return done(err); | ||
expect(response).to.have.property('statusCode', 200); | ||
expect(body[0]).to.have.property('lastModified'); | ||
expect(body[0]).not.to.have.property('_id'); | ||
expect(body[0]).not.to.have.property('name'); | ||
console.log(body) | ||
done(); | ||
}); | ||
}); | ||
}); |
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
289840
1547
219