StaticsetupSets up the Fastify instance with various hooks and handlers.
The Fastify instance to set up.
The configured Fastify instance.
This method configures the Fastify instance with the following:
onRequest hook to log incoming requests and update the last activity time.onResponse hook to log responses with their status codes.setNotFoundHandler to handle 404 errors and log them.StaticstartStarts the Fastify server on the specified port.
The Fastify instance to start.
The port number on which the server should listen.
The
AppServerclass provides static methods to set up and start a Fastify server. This class cannot be instantiated.Remarks
The
setupFastifymethod configures the Fastify instance with various hooks and handlers, including logging for incoming requests and responses, periodic idle time checks, and a 404 not found handler. ThestartFastifymethod starts the Fastify server on a specified port and handles any errors that occur during startup.Example