Skip to content

Commit 47af02e

Browse files
docs: updated README
1 parent b945f99 commit 47af02e

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

packages/errorHandler/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# @prefabs.tech/fastify-error-handler
22

3-
A [Fastify](https://github.com/fastify/fastify) plugin that defines an opinionated config for an API.
3+
A [Fastify](https://github.com/fastify/fastify) plugin that provides an easy integration of error handler in fastify API.
44

55
## Requirements
66

77
* [@prefabs.tech/fastify-config](../config/)
8+
* [@fastify/sensible](https://github.com/fastify/fastify-sensible)
89

910
## Installation
1011

@@ -21,3 +22,31 @@ pnpm add --filter "@scope/project @prefabs.tech/fastify-error-handler
2122
```
2223
2324
## Usage
25+
26+
### Register Plugin
27+
28+
Register @prefabs.tech/fastify-error-handler package with your Fastify instance:
29+
30+
```typescript
31+
import errorHandlerPlugin from "@prefabs.tech/fastify-error-handler";
32+
import Fastify from "fastify";
33+
34+
import config from "./config";
35+
36+
const start = async () => {
37+
// Create fastify instance
38+
const fastify = Fastify({
39+
logger: config.logger,
40+
});
41+
42+
// Register fastify-error-handler plugin
43+
await fastify.register(errorHandlerPlugin);
44+
45+
await fastify.listen({
46+
port: config.port,
47+
host: "0.0.0.0",
48+
});
49+
};
50+
51+
start();
52+
```

0 commit comments

Comments
 (0)