Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codyjdalton/default-response
Default response body module for use in web services
https://github.com/codyjdalton/default-response
http http-response http-server response-code rest status status-code
Last synced: 20 days ago
JSON representation
Default response body module for use in web services
- Host: GitHub
- URL: https://github.com/codyjdalton/default-response
- Owner: codyjdalton
- License: mit
- Created: 2016-06-03T17:35:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-14T00:58:46.000Z (over 6 years ago)
- Last Synced: 2024-04-25T01:42:33.086Z (8 months ago)
- Topics: http, http-response, http-server, response-code, rest, status, status-code
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/codyjdalton/default-response.svg?branch=master)](https://travis-ci.org/codyjdalton/default-response) [![Coverage Status](https://coveralls.io/repos/github/codyjdalton/default-response/badge.svg?branch=master)](https://coveralls.io/github/codyjdalton/default-response?branch=master) [![npm version](https://badge.fury.io/js/default-response.svg)](https://badge.fury.io/js/default-response)
# Default Response
Simple API "default message" module for use with RESTful APIs.
## Installation
```{r, engine='shell'}
$ npm i default-response
```## Basic Usage
Include the dependency and call response.status(code):
```javascript
// include default response
const response = require('default-response');// set a status
console.log(response.status(404));
```
Logs:
```json
{
"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
```javascript
// 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:
```json
{
"status": 401,
"message": "Unauthorized",
"developerMessage": "You do not have permission to access the users resource.",
"error": "ClientError"
}
```