Skip to main content

FastifyController

API controller, designed for the Fastify framework. Extends @perseid/server Controller class.


handleError

Handles thrown errors and formats a clean HTTP response.

protected handleError(
error: FastifyError,
request: FastifyRequest,
response: FastifyReply,
): Promise<void>;

Parameters

  • error: Error thrown by fastify.
  • request: Fastify request.
  • response: Fastify response.

Usage

TODO

createEndpoint

Creates a new fastify endpoint from settings.

public createEndpoint(settings: FastifyCustomEndpoint<DataModel>): {
handler: (request: FastifyRequest, response: FastifyReply) => Promise<void>;
};

Parameters

  • response: Fastify response.
  • settings: Endpoint configuration.

Returns

Fastify endpoint to register.

Usage

TODO

createEndpoints

Registers hooks, handlers, auth and CRUD-related endpoints to instance.

public createEndpoints(
instance: Application,
options?: { prefix?: string; },
): Promise<void>;

Parameters

  • settings: Endpoint configuration.
  • instance: Fastify instance to register endpoints and hooks to.
  • options: Additional options to pass to fastify register function.

Usage

TODO