Libraries
    Preparing search index...

    Class ActionResultAbstract

    Abstract base for all HTTP action results.

    Instead of writing directly to res, handlers return an ActionResult instance. The server calls executeAsync() after the middleware pipeline completes, ensuring consistent error handling and content negotiation.

    Use the static factory methods (ActionResult.ok(), .created(), etc.) rather than constructing subclasses directly.

    server.handle(GetUser, ({ params }) => {
    const user = db.find(params.id);
    if (!user) throw new NotFoundError();
    return ActionResult.ok(user);
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Parameters

      • req: IncomingMessage
      • res: ServerResponse
      • contentNegotiator: ContentNegotiator

      Returns Promise<void>

    • 201 Created — serializes value using content negotiation.

      Type Parameters

      • T

      Parameters

      • body: T
      • Optionallocation: string
      • Optionalheaders: Record<string, string>

      Returns JsonResult<201, T>

    • Send a file buffer as a download attachment.

      Parameters

      • content: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>
      • fileName: string
      • contentType: string = 'application/octet-stream'

      Returns FileResult

    • Explicit JSON response with a specific status code. Use the named factories (ok, notFound, etc.) for common codes. This overload is an escape hatch for uncommon status codes.

      Type Parameters

      • T

      Parameters

      • body: T

      Returns JsonResult<200, T>

    • Explicit JSON response with a specific status code. Use the named factories (ok, notFound, etc.) for common codes. This overload is an escape hatch for uncommon status codes.

      Type Parameters

      • S extends number
      • T

      Parameters

      • body: T
      • status: S
      • Optionalheaders: Record<string, string>

      Returns JsonResult<S, T>