Theia API Documentation v1.76.0
    Preparing search index...

    Default implementation of the ExternalApiRouter.

    Implements

    Index

    Constructors

    Properties

    eventStreamFactory: ExternalApiEventStreamFactory
    eventStreams: RestEventStreamRegistration[] = []
    logger: ILogger
    routes: RestRouteRegistration[] = []
    toDispose: DisposableCollection = ...

    Disposed when the routing is rebuilt or the external API server stops.

    Accessors

    • get raw(): Router

      The underlying express router, mounted at the contribution's path behind the token verification. Full-power escape hatch: existing express routers and middlewares can be mounted here unchanged, keeping their own request handling and response format. Errors they do not handle themselves are reduced to the uniform error format and unmatched paths are answered with 404 in that format, their routes are not published in the OpenAPI document, and their build-scoped resources belong in toDispose.

      Returns Router

    Methods

    • Returns the error code written for unhandled client errors: the HTTP status text, except for plain 400s, which keep the established invalid request code.

      Parameters

      • status: number

      Returns string

    • Returns the HTTP status of client errors raised below the contribution's routes, e.g. by the JSON body parsing.

      Parameters

      • error: unknown

      Returns undefined | number

    • Compiles the body schema into a validator returning the validation error messages, or undefined when the body is valid. An invalid schema throws, failing the contribution's configuration.

      Parameters

      Returns (body: unknown) => undefined | string[]

    • Appends the fallback handling that answers unmatched paths below the contribution with 404 and reduces unhandled route errors, including malformed JSON bodies, to the uniform error format. Called by the external API server once the contribution is configured, so that it runs after all contributed routes.

      Returns void

    post