@glandjs/express
Version:
An Express adapter for Gland HTTP protocol layer, enabling classic middleware-based routing within the Gland architecture solution.
55 lines (54 loc) • 3.17 kB
TypeScript
import { HttpContext, type AcceptType, type CookieOptions, type ErrorCallback, type HttpEventCore, type HttpHeaderName, type HttpHeaderValue, type RequestMethod, type SendOptions } from '@glandjs/http';
import type { Dictionary, HttpStatus, Maybe } from '@medishn/toolkit';
import type { Request, Response } from 'express';
import { EventRecord } from '@glandjs/events';
export declare class ExpressContext<TEvents extends EventRecord> extends HttpContext<Request, Response, TEvents> {
constructor(events: HttpEventCore<TEvents>, req: Request, res: Response);
get body(): any;
get path(): string;
get xhr(): boolean;
get stale(): boolean;
get fresh(): boolean;
get method(): RequestMethod;
get hostname(): string;
get ip(): string | undefined;
get protocol(): string;
get secure(): boolean;
get url(): string;
get originalUrl(): string;
get query(): Dictionary<string | string[] | undefined>;
get subdomains(): string[];
get accepts(): (types?: AcceptType) => string | false;
get is(): (type: string | string[]) => string | false | null;
status(code: HttpStatus): this;
redirect(url: string): this;
setCookie(name: string, value: string, options?: CookieOptions): this;
clearCookie(name: string, options?: Partial<CookieOptions>): this;
getCookie(name: string): Maybe<string>;
deleteCookie(name: string, options?: Partial<CookieOptions>): void;
get cookies(): Dictionary<string>;
get signedCookies(): Dictionary<string>;
send(data: any, statusCode?: number, headers?: Dictionary<HttpHeaderName | HttpHeaderName[]>): this;
json(data: any, statusCode?: number, headers?: Dictionary<HttpHeaderName | HttpHeaderName[]>): this;
html(html: string, statusCode?: number, headers?: Dictionary<HttpHeaderName | HttpHeaderName[]>): this;
text(text: string, statusCode?: number, headers?: Dictionary<HttpHeaderName | HttpHeaderName[]>): this;
xml(xml: string, statusCode?: number, headers?: Dictionary<HttpHeaderName | HttpHeaderName[]>): this;
format(formatters: Dictionary<() => void>): this;
sendFile(filePath: string, options?: SendOptions, fn?: ErrorCallback): this;
jsonp(data: any): this;
sse(): this;
download(filePath: string, filename: string, options?: SendOptions): this;
render(view: string, options?: Dictionary<any>, callback?: (err: Error, html: string) => void): this;
end(): this;
hasHeader(name: HttpHeaderName): boolean;
getHeader<T extends string, THeaders extends string>(name: HttpHeaderName<T>): HttpHeaderValue<T, THeaders> | undefined;
getHeader(name: string): string | string[] | undefined;
getHeader(name: HttpHeaderName): string | string[] | undefined;
setHeader<T extends string, XHeaders extends string>(name: HttpHeaderName<T>, value: HttpHeaderValue<T, XHeaders>): this;
setHeaders(headers: Dictionary<HttpHeaderName | HttpHeaderName[]>): this;
removeHeader<T extends string>(name: HttpHeaderName<T, string>): this;
get headers(): Dictionary<string | string[]>;
vary(fields: string): this;
attachment(filename?: string): this;
location(url: string): this;
}