Skip to content

codyjdalton/default-response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status npm version

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"
}