@kaito-http/core 2.2.1 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,10 +13,10 @@ export declare type ContextWithInput<Ctx, Input> = {
|
|
|
13
13
|
input: Input;
|
|
14
14
|
};
|
|
15
15
|
declare type Values<T> = T[keyof T];
|
|
16
|
-
export declare type Proc<Ctx, Result, Input extends z.ZodTypeAny | Never = Never> =
|
|
16
|
+
export declare type Proc<Ctx, Result, Input extends z.ZodTypeAny | Never = Never> = {
|
|
17
17
|
input?: Input;
|
|
18
18
|
run(arg: ContextWithInput<Ctx, Input extends ZodTypeAny ? z.infer<Input> : undefined>): Promise<Result>;
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
export interface RouterProc<Path extends string, M extends Method> {
|
|
21
21
|
method: M;
|
|
22
22
|
path: Path;
|
|
@@ -29,93 +29,25 @@ export declare type AnyRouter<Ctx> = Router<Ctx, AnyProcs<Ctx>>;
|
|
|
29
29
|
export declare class Router<Ctx, Procs extends AnyProcs<Ctx>> {
|
|
30
30
|
private readonly procs;
|
|
31
31
|
private readonly _procsArray;
|
|
32
|
+
private static patternize;
|
|
32
33
|
constructor(procs: Procs);
|
|
33
34
|
getProcs(): Procs;
|
|
34
|
-
find(method: Method, url: string): (
|
|
35
|
-
input?: z.ZodTypeAny | undefined;
|
|
36
|
-
run(arg: ContextWithInput<Ctx, any>): Promise<unknown>;
|
|
37
|
-
}> & RouterProc<string, Method>) | null;
|
|
35
|
+
find(method: Method, url: string): (Proc<Ctx, unknown, z.ZodTypeAny> & RouterProc<string, Method>) | null;
|
|
38
36
|
private readonly create;
|
|
39
|
-
readonly merge: <Prefix extends string, NewCtx, NewProcs extends AnyProcs<NewCtx>>(_prefix: (Prefix extends `${infer U}/` ? U : Prefix) extends `/${infer U_1}` ? `/${U_1}` : `/${Prefix extends `${infer U}/` ? U : Prefix}`, router: Router<NewCtx, NewProcs>) => Router<NewCtx & Ctx, Procs & { [P in
|
|
37
|
+
readonly merge: <Prefix extends string, NewCtx, NewProcs extends AnyProcs<NewCtx>>(_prefix: (Prefix extends `${infer U}/` ? U : Prefix) extends `/${infer U_1}` ? `/${U_1}` : `/${Prefix extends `${infer U}/` ? U : Prefix}`, router: Router<NewCtx, NewProcs>) => Router<NewCtx & Ctx, Procs & { [P in Extract<keyof NewProcs, "string"> as `/${Prefix}${P}`]: Omit<NewProcs[P], "path"> & {
|
|
40
38
|
path: P;
|
|
41
39
|
}; }>;
|
|
42
|
-
readonly get: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "
|
|
49
|
-
readonly
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`,
|
|
53
|
-
input?: Input | undefined;
|
|
54
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
55
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "POST">>>;
|
|
56
|
-
readonly put: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
57
|
-
input?: Input | undefined;
|
|
58
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
59
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
60
|
-
input?: Input | undefined;
|
|
61
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
62
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "PUT">>>;
|
|
63
|
-
readonly patch: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
64
|
-
input?: Input | undefined;
|
|
65
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
66
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
67
|
-
input?: Input | undefined;
|
|
68
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
69
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "PATCH">>>;
|
|
70
|
-
readonly delete: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
71
|
-
input?: Input | undefined;
|
|
72
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
73
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
74
|
-
input?: Input | undefined;
|
|
75
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
76
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "DELETE">>>;
|
|
77
|
-
readonly head: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
78
|
-
input?: Input | undefined;
|
|
79
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
80
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
81
|
-
input?: Input | undefined;
|
|
82
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
83
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "HEAD">>>;
|
|
84
|
-
readonly options: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
85
|
-
input?: Input | undefined;
|
|
86
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
87
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
88
|
-
input?: Input | undefined;
|
|
89
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
90
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "OPTIONS">>>;
|
|
91
|
-
readonly connect: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
92
|
-
input?: Input | undefined;
|
|
93
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
94
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
95
|
-
input?: Input | undefined;
|
|
96
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
97
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "CONNECT">>>;
|
|
98
|
-
readonly trace: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
99
|
-
input?: Input | undefined;
|
|
100
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
101
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
102
|
-
input?: Input | undefined;
|
|
103
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
104
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "TRACE">>>;
|
|
105
|
-
readonly acl: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
106
|
-
input?: Input | undefined;
|
|
107
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
108
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
109
|
-
input?: Input | undefined;
|
|
110
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
111
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "ACL">>>;
|
|
112
|
-
readonly bind: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Readonly<{
|
|
113
|
-
input?: Input | undefined;
|
|
114
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
115
|
-
}>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Readonly<{
|
|
116
|
-
input?: Input | undefined;
|
|
117
|
-
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
118
|
-
}> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "BIND">>>;
|
|
40
|
+
readonly get: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "GET">>>;
|
|
41
|
+
readonly post: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "POST">>>;
|
|
42
|
+
readonly put: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "PUT">>>;
|
|
43
|
+
readonly patch: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "PATCH">>>;
|
|
44
|
+
readonly delete: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "DELETE">>>;
|
|
45
|
+
readonly head: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "HEAD">>>;
|
|
46
|
+
readonly options: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "OPTIONS">>>;
|
|
47
|
+
readonly connect: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "CONNECT">>>;
|
|
48
|
+
readonly trace: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "TRACE">>>;
|
|
49
|
+
readonly acl: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "ACL">>>;
|
|
50
|
+
readonly bind: <Path extends string, Result, Input extends z.ZodTypeAny>(path: (Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, proc: Proc<Ctx, Result, Input>) => Router<Ctx, Procs & Record<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, Proc<Ctx, Result, Input> & RouterProc<(Path extends `${infer U}/` ? U : Path) extends `/${infer U_1}` ? `/${U_1}` : `/${Path extends `${infer U}/` ? U : Path}`, "BIND">>>;
|
|
119
51
|
}
|
|
120
52
|
export declare class KaitoError extends Error {
|
|
121
53
|
readonly status: number;
|
|
@@ -244,10 +244,14 @@ function createGetContext(getContext) {
|
|
|
244
244
|
return getContext;
|
|
245
245
|
}
|
|
246
246
|
class Router {
|
|
247
|
+
static patternize(path) {
|
|
248
|
+
var normalized = normalizePath(path);
|
|
249
|
+
return new RegExp("^".concat(normalized, "/?$"), 'i');
|
|
250
|
+
}
|
|
251
|
+
|
|
247
252
|
constructor(procs) {
|
|
248
253
|
_defineProperty(this, "create", method => (path, proc) => {
|
|
249
|
-
var
|
|
250
|
-
var pattern = new RegExp("^".concat(stripped, "/?$"), 'i');
|
|
254
|
+
var pattern = Router.patternize(path);
|
|
251
255
|
|
|
252
256
|
var merged = _objectSpread2(_objectSpread2({}, this.procs), {}, {
|
|
253
257
|
[path]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
@@ -263,11 +267,12 @@ class Router {
|
|
|
263
267
|
_defineProperty(this, "merge", (_prefix, router) => {
|
|
264
268
|
var prefix = normalizePath(_prefix);
|
|
265
269
|
var newProcs = Object.entries(router.getProcs()).reduce((all, entry) => {
|
|
266
|
-
var [
|
|
267
|
-
var
|
|
270
|
+
var [path, proc] = entry;
|
|
271
|
+
var newPath = "".concat(prefix).concat(normalizePath(path));
|
|
268
272
|
return _objectSpread2(_objectSpread2({}, all), {}, {
|
|
269
273
|
["".concat(prefix).concat(path)]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
270
|
-
path:
|
|
274
|
+
path: newPath,
|
|
275
|
+
pattern: Router.patternize(newPath)
|
|
271
276
|
})
|
|
272
277
|
});
|
|
273
278
|
}, {});
|
|
@@ -244,10 +244,14 @@ function createGetContext(getContext) {
|
|
|
244
244
|
return getContext;
|
|
245
245
|
}
|
|
246
246
|
class Router {
|
|
247
|
+
static patternize(path) {
|
|
248
|
+
var normalized = normalizePath(path);
|
|
249
|
+
return new RegExp("^".concat(normalized, "/?$"), 'i');
|
|
250
|
+
}
|
|
251
|
+
|
|
247
252
|
constructor(procs) {
|
|
248
253
|
_defineProperty(this, "create", method => (path, proc) => {
|
|
249
|
-
var
|
|
250
|
-
var pattern = new RegExp("^".concat(stripped, "/?$"), 'i');
|
|
254
|
+
var pattern = Router.patternize(path);
|
|
251
255
|
|
|
252
256
|
var merged = _objectSpread2(_objectSpread2({}, this.procs), {}, {
|
|
253
257
|
[path]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
@@ -263,11 +267,12 @@ class Router {
|
|
|
263
267
|
_defineProperty(this, "merge", (_prefix, router) => {
|
|
264
268
|
var prefix = normalizePath(_prefix);
|
|
265
269
|
var newProcs = Object.entries(router.getProcs()).reduce((all, entry) => {
|
|
266
|
-
var [
|
|
267
|
-
var
|
|
270
|
+
var [path, proc] = entry;
|
|
271
|
+
var newPath = "".concat(prefix).concat(normalizePath(path));
|
|
268
272
|
return _objectSpread2(_objectSpread2({}, all), {}, {
|
|
269
273
|
["".concat(prefix).concat(path)]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
270
|
-
path:
|
|
274
|
+
path: newPath,
|
|
275
|
+
pattern: Router.patternize(newPath)
|
|
271
276
|
})
|
|
272
277
|
});
|
|
273
278
|
}, {});
|
|
@@ -235,10 +235,14 @@ function createGetContext(getContext) {
|
|
|
235
235
|
return getContext;
|
|
236
236
|
}
|
|
237
237
|
class Router {
|
|
238
|
+
static patternize(path) {
|
|
239
|
+
var normalized = normalizePath(path);
|
|
240
|
+
return new RegExp("^".concat(normalized, "/?$"), 'i');
|
|
241
|
+
}
|
|
242
|
+
|
|
238
243
|
constructor(procs) {
|
|
239
244
|
_defineProperty(this, "create", method => (path, proc) => {
|
|
240
|
-
var
|
|
241
|
-
var pattern = new RegExp("^".concat(stripped, "/?$"), 'i');
|
|
245
|
+
var pattern = Router.patternize(path);
|
|
242
246
|
|
|
243
247
|
var merged = _objectSpread2(_objectSpread2({}, this.procs), {}, {
|
|
244
248
|
[path]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
@@ -254,11 +258,12 @@ class Router {
|
|
|
254
258
|
_defineProperty(this, "merge", (_prefix, router) => {
|
|
255
259
|
var prefix = normalizePath(_prefix);
|
|
256
260
|
var newProcs = Object.entries(router.getProcs()).reduce((all, entry) => {
|
|
257
|
-
var [
|
|
258
|
-
var
|
|
261
|
+
var [path, proc] = entry;
|
|
262
|
+
var newPath = "".concat(prefix).concat(normalizePath(path));
|
|
259
263
|
return _objectSpread2(_objectSpread2({}, all), {}, {
|
|
260
264
|
["".concat(prefix).concat(path)]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
261
|
-
path:
|
|
265
|
+
path: newPath,
|
|
266
|
+
pattern: Router.patternize(newPath)
|
|
262
267
|
})
|
|
263
268
|
});
|
|
264
269
|
}, {});
|