File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ ` ` `
You can’t perform that action at this time.
0 commit comments