diesel-core
Version:
Web framework built on Web Standards
40 lines (39 loc) • 2 kB
TypeScript
import { Server } from "bun";
import type { CookieOptions } from "./types";
export declare class Context {
req: Request;
server: Server | null;
path: string | null;
paramNames: string[] | Record<string, string>;
env: Record<string, any> | null;
executionContext: any | null;
headers: Headers | null;
private parsedQuery;
private parsedParams;
private parsedCookies;
private parsedBody;
private contextData;
private urlObject;
constructor(req: Request, server: Server | null, path: string | null, paramNames: string[] | Record<string, string>, env: Record<string, any> | null, executionContext: any | null);
setHeader(key: string, value: string): this;
removeHeader(key: string): this;
set<T>(key: string, value: T): this;
get<T>(key: string): T | undefined;
get ip(): string | null;
get url(): URL;
get query(): Record<string, string>;
get params(): Record<string, string>;
get body(): Promise<any>;
text(data: string, status?: number, customHeaders?: Record<string, string>): Response;
send<T>(data: T, status?: number, customHeaders?: Record<string, string>): Response;
json<T>(object: T, status?: number, customHeaders?: Record<string, string>): Response;
file(filePath: string, mimeType?: string, status?: number, customHeaders?: Record<string, string>): Response;
ejs(viewPath: string, data?: {}, status?: number): Promise<void>;
redirect(path: string, status?: number): Response;
setCookie(name: string, value: string, options?: CookieOptions): this;
get cookies(): Record<string, string>;
stream(callback: (controller: ReadableStreamDefaultController) => void): Response;
yieldStream(callback: () => AsyncIterable<any>): Response;
}
export declare function extractParam(paramNames: string[], incomingPath: string): Record<string, string>;
export declare function extractDynamicParams(originalPath: string, incomingPath: string): Record<string, string> | null;