node-http-error
Simple Express HTTP error response middleware.
Features
- Simple API error responses.
Installation
This package is available on NPM:
$ yarn add allanchau-http-error
Usage
A simple example:
// App.const app = ;const httpError = ; app; app; // Returns// {// "code": "400",// "message": "Oops something went wrong.",// } app; // Returns the same thing// {// "code": "400",// "message": "Oops something went wrong.",// } app; // Returns// {// "code": "ERRBADREQUEST",// "message": "Oops something went wrong.",// }
You can also provide some defaults for the route.
app; app; // Returns// {// "code": "ERRNOTAUTHORIZED",// "message": "The user is not authorized.",// }