3.1.4 • Published 6 months ago

@types/trouter v3.1.4

Weekly downloads
5,132
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/trouter

Summary

This package contains type definitions for trouter (https://github.com/lukeed/trouter).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/trouter.

index.d.ts

// Type definitions for trouter 3.1
// Project: https://github.com/lukeed/trouter
// Definitions by: DefinitelyTyped <https://github.com/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

declare namespace Trouter {
    interface FindResult<T> {
        params: { [k: string]: string; };
        handlers: T[];
    }

    type HTTPMethod =
        | 'ACL'
        | 'BIND'
        | 'CHECKOUT'
        | 'CONNECT'
        | 'COPY'
        | 'DELETE'
        | 'GET'
        | 'HEAD'
        | 'LINK'
        | 'LOCK'
        | 'M-SEARCH'
        | 'MERGE'
        | 'MKACTIVITY'
        | 'MKCALENDAR'
        | 'MKCOL'
        | 'MOVE'
        | 'NOTIFY'
        | 'OPTIONS'
        | 'PATCH'
        | 'POST'
        | 'PROPFIND'
        | 'PROPPATCH'
        | 'PURGE'
        | 'PUT'
        | 'REBIND'
        | 'REPORT'
        | 'SEARCH'
        | 'SOURCE'
        | 'SUBSCRIBE'
        | 'TRACE'
        | 'UNBIND'
        | 'UNLINK'
        | 'UNLOCK'
        | 'UNSUBSCRIBE';
}

declare class Trouter<T = any> {
    use(pattern: string | RegExp, ...handlers: T[]): this;

    find(method: Trouter.HTTPMethod, url: string): Trouter.FindResult<T>;

    add(method: Trouter.HTTPMethod, pattern: string | RegExp, ...handlers: T[]): this;

    all(pattern: string | RegExp, ...handlers: T[]): this;

    get(pattern: string | RegExp, ...handlers: T[]): this;

    head(pattern: string | RegExp, ...handlers: T[]): this;

    patch(pattern: string | RegExp, ...handlers: T[]): this;

    options(pattern: string | RegExp, ...handlers: T[]): this;

    connect(pattern: string | RegExp, ...handlers: T[]): this;

    delete(pattern: string | RegExp, ...handlers: T[]): this;

    trace(pattern: string | RegExp, ...handlers: T[]): this;

    post(pattern: string | RegExp, ...handlers: T[]): this;

    put(pattern: string | RegExp, ...handlers: T[]): this;
}

export = Trouter;

Additional Details

  • Last updated: Thu, 23 Dec 2021 23:35:56 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by DefinitelyTyped.