Documentation
    Preparing search index...

    Api Server adapter wrapping the express framework. Maps Quatrain's standardized ServerAdapter interfaces to native Express mechanisms.

    Implements

    Index

    Constructors

    • Parameters

      • appOrRouter: Application | Router = ...
      • config: { apiPrefix?: string } = {}

      Returns ExpressAdapter

    Methods

    • Composes and mounts a full EndpointHandler block at a specific root.

      Parameters

      • handler: EndpointHandler

        The endpoint initialization logic.

      • endpointRoot: string

        The base URI.

      • options: EndpointOptions = {}

        Middlewares and operational options.

      Returns void

    • Injects a Quatrain-compatible API middleware into the flow.

      Parameters

      Returns void

    • Spawns an isolated routing scope (sub-router).

      Parameters

      • path: string

        The prefix path for the router.

      Returns ServerAdapter

      A new ExpressAdapter instance controlling the sub-router.

    • Registers a DELETE endpoint.

      Parameters

      • path: string

        The URI path.

      • ...handlers: any[]

        Standard Quatrain ApiHandlers or native Express middlewares.

      Returns void

    • Registers a GET endpoint.

      Parameters

      • path: string

        The URI path.

      • ...handlers: any[]

        Standard Quatrain ApiHandlers or native Express middlewares.

      Returns void

    • Retrieves the underlying native framework instance.

      Returns any

      The raw Express Application or Router instance.

    • Registers a PATCH endpoint.

      Parameters

      • path: string

        The URI path.

      • ...handlers: any[]

        Standard Quatrain ApiHandlers or native Express middlewares.

      Returns void

    post

    • post(path: string, ...handlers: any[]): void

      Registers a POST endpoint.

      Parameters

      • path: string

        The URI path.

      • ...handlers: any[]

        Standard Quatrain ApiHandlers or native Express middlewares.

      Returns void

    • Registers a PUT endpoint.

      Parameters

      • path: string

        The URI path.

      • ...handlers: any[]

        Standard Quatrain ApiHandlers or native Express middlewares.

      Returns void

    • Configures the server to serve static files from a specified folder. It also sets up a fallback route for SPA (Single Page Application) navigation, ensuring that non-API routes return the main index.html file.

      Parameters

      • folderPath: string

        The absolute path to the directory containing static files (e.g. built frontend).

      • apiPrefix: string = '/api'

        The prefix used for API routes, which will be ignored by the SPA fallback. Defaults to '/api'.

      Returns void

    • Binds the server to the network and starts listening.

      Parameters

      • port: number

        The network port.

      • Optionalcallback: () => void

        Optional completion callback.

      Returns void

    • Attaches a native Express middleware, path prefix, or sub-router.

      Parameters

      • ...args: any[]

        Arguments forwarded directly to express.use (e.g. path and RequestHandlers).

      Returns void