Skip to main content

ExpressController

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


handleError

Handles thrown errors and formats a clean HTTP response.

protected handleError(
error: unknown,
request: Request,
response: Response,
next: NextFunction,
): void;

Parameters

  • error: Error thrown by express.
  • request: Express request.
  • response: Express response.

Usage

TODO

createEndpoint

Creates a new express endpoint from settings.

public createEndpoint(settings: ExpressCustomEndpoint<DataModel>): {
handler: RequestHandler;
};

Parameters

  • response: Express response.
  • settings: Endpoint configuration.

Returns

Express 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: Express instance to register endpoints and hooks to.
  • options: Additional options to pass to express register function.

Usage

TODO