-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
118 lines (106 loc) · 2.84 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import * as Koa from "koa"
import * as FindMyWay from "find-my-way"
/**
* Router middleware for koa. Based on find-my-way, a crazy fast http radix based router.
*
* @param options All options are passed directly to `find-my-way`.
*/
declare function Router(options?: FindMyWay.Config<FindMyWay.HTTPVersion>): Router.Instance
declare namespace Router {
interface Context extends Koa.Context {
/**
* url params
*/
params: { [key: string]: string | undefined }
}
interface ShortHandRoute {
/**
* Register a new route.
*
* @param path Route path
* @param middlewares Koa.js middleware
*/
(path: string, ...middlewares: Koa.Middleware[]): Instance
}
interface Instance {
/**
* Register a new route.
*
* @param method HTTP method
* @param path Route path
* @param middlewares Koa.js middleware
*/
on(
method: FindMyWay.HTTPMethod | FindMyWay.HTTPMethod[],
path: string,
...middlewares: Koa.Middleware[]
): this
/**
* Deregister a route.
*
* @param method HTTP method
* @param path Route path
*/
off(method: FindMyWay.HTTPMethod | FindMyWay.HTTPMethod[], path: string): void
/**
* Return (if present) the route registered in `method:path`.
*
* @param method HTTP method
* @param path The path must be sanitized, all the parameters and wildcards are decoded automatically.
* @param version
*/
find(
method: FindMyWay.HTTPMethod,
path: string,
version?: string
): FindMyWay.FindResult<FindMyWay.HTTPVersion> | null
/**
* Returns router middleware which dispatches a route matching the request.
*/
routes(): Koa.Middleware
/**
* Empty router.
*/
reset(): void
/**
* Prints the representation of the internal radix tree, useful for debugging.
*/
prettyPrint(): string
all: ShortHandRoute
acl: ShortHandRoute
bind: ShortHandRoute
checkout: ShortHandRoute
connect: ShortHandRoute
copy: ShortHandRoute
delete: ShortHandRoute
get: ShortHandRoute
head: ShortHandRoute
link: ShortHandRoute
lock: ShortHandRoute
'm-search': ShortHandRoute
merge: ShortHandRoute
mkactivity: ShortHandRoute
mkcalendar: ShortHandRoute
mkcol: ShortHandRoute
move: ShortHandRoute
notify: ShortHandRoute
options: ShortHandRoute
patch: ShortHandRoute
post: ShortHandRoute
propfind: ShortHandRoute
proppatch: ShortHandRoute
purge: ShortHandRoute
put: ShortHandRoute
rebind: ShortHandRoute
report: ShortHandRoute
search: ShortHandRoute
source: ShortHandRoute
subscribe: ShortHandRoute
trace: ShortHandRoute
unbind: ShortHandRoute
unlink: ShortHandRoute
unlock: ShortHandRoute
unsubscribe: ShortHandRoute
}
}
export = Router