@whi/restful-json-api
v0.2.7
Published
A tool for rapid restful API development
Downloads
17
Readme
Restful JSON API
A tool for rapid restful API development.
Overview
Features
async/await
syntax for deterministic response- Automatic
404
,405
, and501
responses - Strict and specific misconfiguration errors for rapid development
- Detailed error types using
@whi/serious-error-types
- Flexible directive structure
- Derived API documentation
Usage
Install
npm install @whi/restful-json-api
Import
const { RestfulAPI } = require('@whi/restful-json-api');
Javascript API
Automatic Assistants
404 Not Found
Automatically returned when
- the endpoint has been defined
- and, the request method is not defined
- and, the request method is GET or HEAD
HTTP specification states that servers must support GET and HEAD methods. So instead of 405 or 501 we return a 404 to indicate that the endpoint is valid but empty.
405 Method Not Allowed
Automatically returned when
- the endpoint has been defined
- and, the request method is supported by this server
- but, this endpoint does not support that request method
It will return the "Allow" header with the endpoint's supported request methods because 405 responses must include the "Allow" header.
501 Not Implemented
Automatically returned when
- the endpoint has been defined
- but, the request method is not supported by this server