Skip to content

Commit

Permalink
πŸ“ Added README
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecarr committed Nov 17, 2021
1 parent 217bb51 commit f4176fa
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# ⚠ Houston

> RFC 7807 compliant errors for Node.js
[![npm](https://img.shields.io/npm/v/moducate/houston)](https://npmjs.com/package/moducate/houston)
[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainabilitymoducate/houston)](https://codeclimate.com/github/moducate/houston)
[![npms.io (quality)](https://img.shields.io/npms-io/final-score/moducate/houston?label=npms.io%20score)](https://api.npms.io/v2/package/moducate/houston)
[![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@moducate/houston)](#)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/moducate/houston)](https://bundlephobia.com/package/moducate/houston)

- πŸ“ƒ **Fully compliant.** Fully compliant with the [RFC 7807 specification](https://datatracker.ietf.org/doc/html/rfc7807).
- πŸ’‘ **Lightweight.**
- πŸ’ͺ **TypeScript.** Fully typed and self-documenting!

## πŸš€ Quick Start

### Install

```bash
# npm
npm i @moducate/houston

# or yarn
yarn add @moducate/houston
```

### Import

```js
// ESM / TypeScript
import { withError } from "@moducate/houston";

// or CommonJS
const { withError } = require("@moducate/houston");
```

### Example Usage

Transform an `express` response:

```js
const { withError } = require("@moducate/houston");
const app = require("express")();

app.get("/not-found", (_, res) => {
return withError(res, { type: "https://example.com/not-found", status: 404 })
});
```

## 🏷 MIME Type

The exported `mime` constant can be used to obtain the media/MIME type for RFC 7807 JSON errors.

```js
const { mime } = require("@moducate/houston");

console.log(mime);
// => 'application/problem+json'
```

This is what the `Content-Type` header of the response supplied to `withError` is set to.

## βš– License

Houston is licensed under the [`MIT License`](LICENSE).

0 comments on commit f4176fa

Please sign in to comment.