rest-vir - v2.2.0
    Preparing search index...

    Type Alias EndpointMethodImplementationOutput<Endpoint, Method>

    EndpointMethodImplementationOutput: EndpointMethodDefinedStatusOutputs<
        Endpoint,
        Method,
    > extends infer DefinedStatuses extends AnyObject
        ? RequireExactlyOne<
            DefinedStatuses & Record<
                Exclude<ErrorHttpStatus, keyof DefinedStatuses>,
                {
                    headers?: DefaultOutgoingResponseHeadersType;
                    responseData: DefaultErrorResponseType;
                },
            > & {
                [Status in Exclude<ErrorHttpStatus, keyof DefinedStatuses>]: SetNullishPropertiesAsOptional<
                    {
                        headers?: EndpointResponseOutgoingHeadersType<
                            Endpoint,
                            Method,
                            Status,
                        >;
                        responseData: EndpointResponseType<Endpoint, Method, Status>;
                    },
                >
            } & { responseHandled: true },
        >
        : never

    The output an endpoint method implementation must return. Either:

    • Exactly one declared success/error status (with its response data and optional headers),
    • Exactly one undeclared error status (string body),
    • Or {responseHandled: true} to indicate the implementation already wrote the response (e.g. SSE streaming or a hijacked raw response).

    Type Parameters

    // Server-Sent Events: hijack the response, write the stream directly, return
    // {responseHandled: true} so rest-vir leaves it alone.
    [HttpMethod.Get]({response}) {
    response.hijack();
    response.raw.writeHead(HttpStatus.Ok, {
    'content-type': 'text/event-stream',
    'cache-control': 'no-cache',
    'x-no-compression': 'true',
    });
    response.raw.write(`data: hello\n\n`);
    response.raw.end();
    return {responseHandled: true};
    }