Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

FlorianWendelborn/spirit-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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