Static
setupSets 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.Static
startStarts the Fastify server on the specified port.
The Fastify instance to start.
The port number on which the server should listen.
The
AppServer
class provides static methods to set up and start a Fastify server. This class cannot be instantiated.Remarks
The
setupFastify
method 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. ThestartFastify
method starts the Fastify server on a specified port and handles any errors that occur during startup.Example