default-response
v1.2.1
Published
Get a default RESTful response body
Downloads
1,040
Readme
Default Response
Simple API "default message" module for use with RESTful APIs.
Installation
$ npm i default-response
Basic Usage
Include the dependency and call response.status(code):
// include default response
const response = require('default-response');
// set a status
console.log(response.status(404));
Logs:
{
"status": 404,
"message": "Not found",
"developerMessage": "The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible.",
"error": "ClientError"
}
And many, many more...
Custom Developer Messages
// include default response
const response = require('default-response');
// set a status
console.log(
response.statusMessage(
401,
"You do not have permission to access the users resource."
)
);
Logs:
{
"status": 401,
"message": "Unauthorized",
"developerMessage": "You do not have permission to access the users resource.",
"error": "ClientError"
}