Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
*.log
.DS_Store
package-lock.json
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
before_install:
- npm install -g npm@latest
- npm install booljs@latest
node_js:
- 7.0
- lts/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/BoolJS/booljs-express.svg?branch=master)](https://travis-ci.org/BoolJS/booljs-express) [![Dependencies status for bool.js](https://david-dm.org/booljs/booljs-express.svg)](https://david-dm.org/booljs/booljs-express) [![devDependency Status](https://david-dm.org/booljs/booljs-express/dev-status.svg)](https://david-dm.org/booljs/booljs-express#info=devDependencies) [![Code Climate](https://codeclimate.com/github/BoolJS/booljs-express/badges/gpa.svg)](https://codeclimate.com/github/BoolJS/booljs-express) [![Inline docs](http://inch-ci.org/github/booljs/booljs-express.svg?branch=master)](http://inch-ci.org/github/booljs/booljs-express)

[![Bool.js NPM icon](https://nodei.co/npm/booljs-express.png)](https://npmjs.com/packages/booljs-express)
[![Bool.js NPM icon](https://nodei.co/npm/booljs.express.png)](https://npmjs.com/packages/booljs.express)

[![Join the chat at https://gitter.im/BoolJS/booljs-express](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/BoolJS/booljs-express?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
2 changes: 1 addition & 1 deletion example
16 changes: 12 additions & 4 deletions lib/server/router/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
module.exports = function ({ Error, views: { Json } }, router) {
let json = new Json();

// 404 Handler. Acts when a resource call isn't found
router.use((request, response) => json.error(
new Error(404, 'method_not_found', 'Method wasn\'t found'), response
));
// Final handler. Acts when a resource call isn't found
router.use((request, response) => {
const notImplementedError = new Error(501,
'not_implemented', 'Method haven\'t been implemented yet');
if (response.headersSent === false) {
if (request.path === '/' && request.method === 'GET') {
json.standard('Welcome to API!', response);
} else {
json.error(notImplementedError, response);
}
}
});

// Error Handler. Processes an error output view.
router.use((error, req, response, next) => json.error(error, response));
Expand Down
Loading