UNPKG

@jeaks03/overseer

Version:

Just another TypeScript Back-End framework

60 lines (59 loc) 1.66 kB
import { IncomingMessage, ServerResponse } from "http"; import { Router } from "./router"; export declare class AsyncRequestHandler { private serverRequest; private serverResponse; private router; private foundRoute; static doHandle(serverRequest: IncomingMessage, serverResponse: ServerResponse, router: Router): Promise<void>; private constructor(); private handle; /** * Handles possible routing scenarios such as: route exists, resource exists or not found */ private checkAvailableRoute; /** * Triggered when a route was found */ private routeMatched; /** * Triggers the controller method associated with the route * @param info param to pass to controller method */ private handleRoute; /** * Handles the given error * @param e the error * @param info param to pass to error handler method */ private handleError; /** * Generates PathInfo for the controller method to use */ private generatePathInfo; /** * Parses the raw http request body to a string promise */ private parseRequest; /** * Returns the route associated with the current server request */ private findRoute; /** * Adds necessary headers to avoid CORS issues */ private appendInitialHeaders; /** * Handles redirects */ private handleRedirect; /** * Adds necessary headers to avoid CORS issues in case of OPTIONS requests */ private handleCORS; /** * Writes to the http response object * @param output what to write */ private writeResponse; }