JSPM

@types/named-routes

2.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 462
  • Score
    100M100P100Q102410F
  • License MIT

TypeScript definitions for named-routes

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@types/named-routes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    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 express = require("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.