spirit-error
v0.0.5
Published
Easily Return HTTP Errors from Spirit
Downloads
55
Readme
Spirit Error
Easily Return HTTP Errors from Spirit
Supports JSON, HTML, Text and dynamic errors.
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.notFoundReturns 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-erroror use yarn:
yarn add spirit-error