import type { ServerWebSocket } from "bun"; import type { BunRequest } from "./core/request"; import type { BunResponse } from "./core/response"; export type NextFunction = (err?: unknown) => void; export type Handler = (req: BunRequest, res: BunResponse, next: NextFunction) => void; export type ErrorHandler = (err: unknown, req: BunRequest, res: BunResponse, next: NextFunction) => void; export interface RouteDefinition { method: string; path: string; regex: RegExp; keys: string[]; handlers: Handler[]; } export interface RouterOptions { caseSensitive?: boolean; strict?: boolean; mergeParams?: boolean; } export interface TlsOptions { key: string | Buffer; cert: string | Buffer; ca?: string | Buffer | (string | Buffer)[]; passphrase?: string; } export interface ListenOptions { port?: number; hostname?: string; tls?: TlsOptions; } export interface CookieOptions { domain?: string; expires?: Date; httpOnly?: boolean; maxAge?: number; path?: string; sameSite?: "strict" | "lax" | "none" | boolean; secure?: boolean; signed?: boolean; } export interface SendFileOptions { maxAge?: number; root?: string; headers?: Record; dotfiles?: "allow" | "deny" | "ignore"; lastModified?: boolean; cacheControl?: boolean; immutable?: boolean; acceptRanges?: boolean; } export interface UploadedFile { fieldname: string; originalname: string; encoding: string; mimetype: string; size: number; buffer?: Buffer; destination?: string; filename?: string; path?: string; } export declare const BUNWAY_DEFAULT_PORT = 3000; export interface WebSocketData { routePath: string; params: Record; handlers: WebSocketHandlers; req: BunRequest; } export type BunWebSocket = ServerWebSocket; export interface WebSocketHandlers { open?: (ws: BunWebSocket) => void; message?: (ws: BunWebSocket, message: string | Buffer) => void; close?: (ws: BunWebSocket, code: number, reason: string) => void; drain?: (ws: BunWebSocket) => void; } export interface WebSocketRouteDefinition { path: string; regex: RegExp; keys: string[]; handlers: WebSocketHandlers; middlewares: Handler[]; } export interface BunWayLogger { info(message: string, meta?: Record): void; warn(message: string, meta?: Record): void; error(message: string, meta?: Record): void; debug?(message: string, meta?: Record): void; } /** * Extend this interface to type req.user for your application. * @example * declare module "bunway" { * interface AuthUser { * id: string; * email: string; * role: "admin" | "user"; * scope?: string[]; * } * } */ export interface AuthUser { [key: string]: unknown; } //# sourceMappingURL=types.d.ts.map