spirit-error

0.0.5 • Public • Published

Spirit Error

Easily Return HTTP Errors from Spirit

Supports JSON, HTML, Text and dynamic errors.

Slack Build Status Coverage Status NPM Downloads NPM Dependencies

Usage

import spiritError from 'spirit-error'
 
// tell spirit-error to create JSON responses
const error = spiritError({
    type: 'json' // default
})
 
// inside a spirit function
return error.notFound

Returns this HTTP response:

HTTP/1.1 404 Not Found
Content-Type: application/json; charset=utf-8
{
    "error": {
        "message": "Not Found"
    }
}

Install

With npm installed, run

npm install --save spirit-error

or use yarn:

yarn add spirit-error

See Also

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i spirit-error

Weekly Downloads

6

Version

0.0.5

License

MIT

Last publish

Collaborators

  • florianwendelborn