-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.d.ts
26 lines (23 loc) · 1.23 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Thank you: @fwilkerson, @stahlstift
// ---
/** @type {import('http').METHODS} */
type Methods = 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' |'M-SEARCH' | 'MERGE' | 'MKACTIVITY' |'MKCALENDAR' | 'MKCOL' | 'MOVE' |'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PRI' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE';
type Pattern = RegExp | string;
export class Trouter<T = Function> {
find(method: Methods, url: string): {
params: Record<string, string>;
handlers: T[];
};
add(method: Methods, pattern: Pattern, ...handlers: T[]): this;
use(pattern: Pattern, ...handlers: T[]): this;
all(pattern: Pattern, ...handlers: T[]): this;
get(pattern: Pattern, ...handlers: T[]): this;
head(pattern: Pattern, ...handlers: T[]): this;
patch(pattern: Pattern, ...handlers: T[]): this;
options(pattern: Pattern, ...handlers: T[]): this;
connect(pattern: Pattern, ...handlers: T[]): this;
delete(pattern: Pattern, ...handlers: T[]): this;
trace(pattern: Pattern, ...handlers: T[]): this;
post(pattern: Pattern, ...handlers: T[]): this;
put(pattern: Pattern, ...handlers: T[]): this;
}