Skip to content

Commit

Permalink
πŸ“ Added Next.js example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecarr committed Nov 18, 2021
1 parent 7f36e95 commit 4f4f7c7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import { withError } from "@moducate/houston";
const { withError } = require("@moducate/houston");
```

### Example Usage
## πŸ’‘ Examples

Transform an `express` response:
> πŸ“ Full source code for these examples can be found in the `examples` directory.
### Express

```js
const { withError } = require("@moducate/houston");
Expand All @@ -48,6 +50,16 @@ app.get("/not-found", (_, res) => {
});
```

### Next.js API Routes

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

export default function handler(req, res) {
return withError(res, { type: "https://example.com/not-found", status: 404 });
}
```

## πŸ“„ Templates

You can create error templates using the exported `withTemplate` function:
Expand Down

0 comments on commit 4f4f7c7

Please sign in to comment.