@types/named-routes
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

Installation

npm install --save @types/named-routes

Summary

This package contains type definitions for named-routes (https://github.com/alubbe/named-routes#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/named-routes.

index.d.ts

import * as express from "express";

declare module "express-serve-static-core" {
    interface Application {
        namedRoutes: NamedRouter;
    }
    // eslint-disable-next-line @typescript-eslint/naming-convention
    interface IRouterMatcher<T> {
        (path: PathParams, name: string, ...handlers: RequestHandler[]): T;
        (path: PathParams, name: string, ...handlers: RequestHandlerParams[]): T;
    }
}

interface RouterOptions {
    caseSensitive: boolean;
}

interface RouteOptions {
    name: string;
    recursiveWildcard: boolean;
    caseSensitive: boolean;
    wildcardInPairs: boolean;
}

interface RouteParams {
    [key: string]: string | string[] | number | number[] | boolean | boolean[] | null;
}

declare class NamedRouter {
    constructor(options?: Partial<RouterOptions>);
    match(req: express.Request): boolean | object;
    add(
        method: string,
        path: string,
        callbacks: express.RequestHandler | express.RequestHandler[],
        options?: Partial<RouteOptions>,
    ): void;
    build(name: string, params?: RouteParams, method?: string): string;
    registerAppHelpers(app: express.Express): NamedRouter;
    param(name: string, callback: express.RequestHandler): NamedRouter;
    param(callback: express.RequestHandler): NamedRouter;
    dispatch(req: express.Request, res?: express.Response, next?: express.NextFunction): void;
    extendExpress(app: express.Express | express.Router): NamedRouter;
}

export = NamedRouter;

Additional Details

Credits

These definitions were written by Philipp Katz.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/named-routes

Weekly Downloads

275

Version

2.0.5

License

MIT

Unpacked Size

5.77 kB

Total Files

5

Last publish

Collaborators

  • types