@the-teacher/the-router
Version:
Simple router for Express.js, making routes and actions easy to manage.
60 lines • 1.77 kB
TypeScript
import { Router, RequestHandler, RouterOptions } from "express";
export type RouteInfo = {
method: string;
path: string;
action: string;
middlewares: RequestHandler[];
};
/**
* Sets options for Express Router
*/
export declare const setRouterOptions: (options: RouterOptions) => void;
/**
* Returns current router instance or creates a new one if it doesn't exist
*/
export declare const getRouter: () => Router;
/**
* Resets router state to default values
*/
export declare const resetRouter: () => void;
/**
* Sets the path for actions
*/
export declare const setActionsPath: (path: string) => string;
/**
* Checks if a custom actions path is set
*/
export declare const isCustomActionsPath: () => boolean;
/**
* Gets the current actions path
*/
export declare const getActionsPath: () => string;
/**
* Sets the current router scope
*/
export declare const setRouterScope: (scope: string | null) => void;
/**
* Gets the current router scope
*/
export declare const getRouterScope: () => string | null;
/**
* Gets the current scope middlewares
*/
export declare const getScopeMiddlewares: () => RequestHandler[];
/**
* Sets the scope middlewares
*/
export declare const setScopeMiddlewares: (middlewares: RequestHandler[]) => void;
/**
* Adds a route to the routes map
*/
export declare const addRouteToMap: (method: string, path: string | RegExp, action: string, middlewares?: RequestHandler[]) => void;
/**
* Gets the routes map
*/
export declare const getRoutesMap: () => Map<string, RouteInfo>;
/**
* Creates a route scope
*/
export declare const routeScope: (scope: string, middlewaresOrCallback: RequestHandler[] | (() => void), routesDefinitionCallback?: () => void) => void;
//# sourceMappingURL=router-manager.d.ts.map