faker-api
Version:
A fully customizible rest api faking package that allows you to mock , clone and fake Rest API with fake yet realistic data
53 lines • 2.17 kB
TypeScript
import { ViewSet, ViewSetType } from "./viewset";
import { Request, Response } from "express";
declare type ViewSetMapItemType = {
instance: ViewSet;
blueprint: ViewSetType;
};
declare class Router {
/***
* Map that holds various viewset objects with there key been there path prefix
*/
viewsetMap: Map<string, ViewSetMapItemType>;
/***
* Represent the prefix of the router
*/
root?: string;
/**
* Sets the prefix of the router
* @param root - The path prefix of the router
* This method is used by the FakerServer instance when registing a router
*/
set _root(root: string);
/**
* To add or register a new viewset class to a router instance
* @param root - the prefix of the viewset
* @viewset - The class of the actual viewset, the class will be instantiated by the router object here
*/
register(root: string, viewset: new () => ViewSet): void;
/**
* Handles all request that a directed to the router by the faker server instance
* @param request - Express request object of the request
* @param response - Express response object for the request
* @path : The request path without the faker server path prefix
* @returns true if request was handled by any viewset else returns false or undefined
*/
on(request: Request, response: Response, path: string): boolean | undefined;
/**
* To generate a description of the router object
*/
private displayInfo;
/**
* Calls when a viewset root matches the prefix of a request
* This method will basically iterate over all the support path the viewset can handle and check if any matches the request path @path
*
* @param path - The request path
* @viewset - The actual viewset Item whose root matches the prefix of the path
* @param request - Express request object of the request
* @param response - Express response object for the request
* @returns true if the viewset can handle the request method or false | undefined if not
*/
private _handleViewsetRequest;
}
export { Router };
//# sourceMappingURL=index.d.ts.map