Add 404 for GET /:resource

This commit is contained in:
Typicode
2015-04-04 13:17:23 +02:00
parent 840ff0a78e
commit 6ad3acaaab
2 changed files with 12 additions and 1 deletions

View File

@ -41,6 +41,11 @@ module.exports = function(source) {
// GET /*?*&_end=
// GET /*?*&_start=&_end=
function list(req, res, next) {
// Test if resource exists
if (!db.object.hasOwnProperty(req.params.resource)) {
return res.sendStatus(404)
}
// Filters list
var filters = {}

View File

@ -59,6 +59,12 @@ describe('Server', function() {
.expect(db.posts)
.expect(200, done)
})
it('should respond with 404 if resource is not found', function(done) {
request(server)
.get('/undefined')
.expect(404, done)
})
})
describe('GET /:resource?attr=&attr=', function() {