Simple API "default message" module for use with RESTful APIs.
$ npm i default-response
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...
// 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"
}