-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
types.ts
36 lines (31 loc) · 1.45 KB
/
types.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
import { ConnInfo, Handler, ServeInit } from "./deps.ts"
export interface Next {
(err?: Error): void
}
export type Middleware = (request: Request, connInfo: ConnInfo, next: Next) => void
export interface Fastro {
serve(options?: ServeInit): Promise<void>
get(url: string, opts: Handler | Middleware, handler?: Handler): Fastro
post(url: string, opts: Handler | Middleware, handler?: Handler): Fastro
put(url: string, opts: Handler | Middleware, handler?: Handler): Fastro
patch(url: string, opts: Handler | Middleware, handler?: Handler): Fastro
delete(url: string, opts: Handler | Middleware, handler?: Handler): Fastro
head(url: string, opts: Handler | Middleware, handler?: Handler): Fastro
options(url: string, opts: Handler | Middleware, handler?: Handler): Fastro
}
export interface Route {
method: string
url: string
middleware: Handler | Middleware
handler: Handler
}
export interface Router {
get(url: string, opts: Handler | Middleware, handler: Handler): Router
post(url: string, opts: Handler | Middleware, handler: Handler): Router
put(url: string, opts: Handler | Middleware, handler: Handler): Router
patch(url: string, opts: Handler | Middleware, handler: Handler): Router
delete(url: string, opts: Handler | Middleware, handler: Handler): Router
head(url: string, opts: Handler | Middleware, handler: Handler): Router
options(url: string, opts: Handler | Middleware, handler: Handler): Router
router: Map<string, Route>
}