Skip to main content
Module

x/fastro/server/types.ts

Fast and simple web application framework for deno
Go to Latest
File
import { ConnInfo, Handler } from "./deps.ts"
export type StringHandler = (request?: Request, connInfo?: ConnInfo) => stringexport interface Router { routes: Map<string, Route> get(path: PathArgument, ...handlers: HandlerArgument[]): Router post(path: PathArgument, ...handlers: HandlerArgument[]): Router put(path: PathArgument, ...handlers: HandlerArgument[]): Router delete(path: PathArgument, ...handlers: HandlerArgument[]): Router patch(path: PathArgument, ...handlers: HandlerArgument[]): Router head(path: PathArgument, ...handlers: HandlerArgument[]): Router options(path: PathArgument, ...handlers: HandlerArgument[]): Router}
export type PathArgument = string | RegExp
export interface Next { (error?: unknown): void}export type RequestHandler = ( request: Request, connInfo: ConnInfo, next: Next,) => void | Promise<void> | string | Promise<string> | Response | Promise<Response>
export type HandlerArgument = Handler | RequestHandler | RequestHandler[]export type Route = { method: string path: PathArgument handlers: HandlerArgument[]}
export interface Dependency { deps: Map<string, unknown> set(key: string, val: unknown): Dependency get(key: string): unknown}export type MiddlewareArgument = | Dependency | PathArgument | Router | RequestHandler | RequestHandler[]
export interface AppMiddleware { type: string path: PathArgument middlewares: MiddlewareArgument[]}