@kaito-http/core 2.3.4 → 2.3.5
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.
|
@@ -2,51 +2,57 @@ import fmw, { HTTPMethod, Instance } from 'find-my-way';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { Route } from './route';
|
|
4
4
|
import { ServerConfig } from './server';
|
|
5
|
-
import { NormalizePath } from './util';
|
|
6
|
-
export declare type RoutesInit<Context
|
|
7
|
-
[Path in
|
|
5
|
+
import { NoEmpty, NormalizePath, Values } from './util';
|
|
6
|
+
export declare type RoutesInit<Context> = {
|
|
7
|
+
[Path in string]: Route<any, Path, HTTPMethod, Context, z.ZodSchema>;
|
|
8
8
|
};
|
|
9
9
|
export declare class Router<Context, Routes extends RoutesInit<Context>> {
|
|
10
|
-
static
|
|
11
|
-
private static
|
|
10
|
+
static create<Context = null>(): Router<Context, {}>;
|
|
11
|
+
private static handle;
|
|
12
12
|
readonly 'routes': Routes;
|
|
13
|
-
readonly 'acl': <Result, Path extends string
|
|
14
|
-
readonly 'bind': <Result, Path extends string
|
|
15
|
-
readonly 'checkout': <Result, Path extends string
|
|
16
|
-
readonly 'connect': <Result, Path extends string
|
|
17
|
-
readonly 'copy': <Result, Path extends string
|
|
18
|
-
readonly 'delete': <Result, Path extends string
|
|
19
|
-
readonly 'get': <Result, Path extends string
|
|
20
|
-
readonly 'head': <Result, Path extends string
|
|
21
|
-
readonly 'link': <Result, Path extends string
|
|
22
|
-
readonly 'lock': <Result, Path extends string
|
|
23
|
-
readonly '
|
|
24
|
-
readonly 'mkactivity': <Result, Path extends string
|
|
25
|
-
readonly 'mkcalendar': <Result, Path extends string
|
|
26
|
-
readonly 'mkcol': <Result, Path extends string
|
|
27
|
-
readonly 'move': <Result, Path extends string
|
|
28
|
-
readonly 'notify': <Result, Path extends string
|
|
29
|
-
readonly 'options': <Result, Path extends string
|
|
30
|
-
readonly 'patch': <Result, Path extends string
|
|
31
|
-
readonly 'post': <Result, Path extends string
|
|
32
|
-
readonly 'propfind': <Result, Path extends string
|
|
33
|
-
readonly 'proppatch': <Result, Path extends string
|
|
34
|
-
readonly 'purge': <Result, Path extends string
|
|
35
|
-
readonly 'put': <Result, Path extends string
|
|
36
|
-
readonly 'rebind': <Result, Path extends string
|
|
37
|
-
readonly 'report': <Result, Path extends string
|
|
38
|
-
readonly 'search': <Result, Path extends string
|
|
39
|
-
readonly 'source': <Result, Path extends string
|
|
40
|
-
readonly 'subscribe': <Result, Path extends string
|
|
41
|
-
readonly 'trace': <Result, Path extends string
|
|
42
|
-
readonly 'unbind': <Result, Path extends string
|
|
43
|
-
readonly 'unlink': <Result, Path extends string
|
|
44
|
-
readonly 'unlock': <Result, Path extends string
|
|
45
|
-
readonly 'unsubscribe': <Result, Path extends string
|
|
13
|
+
readonly 'acl': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "ACL", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "ACL", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "ACL", Context, Input>; }>;
|
|
14
|
+
readonly 'bind': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "BIND", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "BIND", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "BIND", Context, Input>; }>;
|
|
15
|
+
readonly 'checkout': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "CHECKOUT", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "CHECKOUT", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "CHECKOUT", Context, Input>; }>;
|
|
16
|
+
readonly 'connect': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "CONNECT", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "CONNECT", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "CONNECT", Context, Input>; }>;
|
|
17
|
+
readonly 'copy': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "COPY", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "COPY", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "COPY", Context, Input>; }>;
|
|
18
|
+
readonly 'delete': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "DELETE", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "DELETE", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "DELETE", Context, Input>; }>;
|
|
19
|
+
readonly 'get': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "GET", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "GET", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "GET", Context, Input>; }>;
|
|
20
|
+
readonly 'head': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "HEAD", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "HEAD", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "HEAD", Context, Input>; }>;
|
|
21
|
+
readonly 'link': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "LINK", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "LINK", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "LINK", Context, Input>; }>;
|
|
22
|
+
readonly 'lock': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "LOCK", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "LOCK", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "LOCK", Context, Input>; }>;
|
|
23
|
+
readonly 'm_search': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "M-SEARCH", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "M-SEARCH", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "M-SEARCH", Context, Input>; }>;
|
|
24
|
+
readonly 'mkactivity': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "MKACTIVITY", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "MKACTIVITY", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "MKACTIVITY", Context, Input>; }>;
|
|
25
|
+
readonly 'mkcalendar': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "MKCALENDAR", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "MKCALENDAR", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "MKCALENDAR", Context, Input>; }>;
|
|
26
|
+
readonly 'mkcol': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "MKCOL", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "MKCOL", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "MKCOL", Context, Input>; }>;
|
|
27
|
+
readonly 'move': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "MOVE", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "MOVE", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "MOVE", Context, Input>; }>;
|
|
28
|
+
readonly 'notify': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "NOTIFY", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "NOTIFY", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "NOTIFY", Context, Input>; }>;
|
|
29
|
+
readonly 'options': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "OPTIONS", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "OPTIONS", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "OPTIONS", Context, Input>; }>;
|
|
30
|
+
readonly 'patch': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "PATCH", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "PATCH", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "PATCH", Context, Input>; }>;
|
|
31
|
+
readonly 'post': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "POST", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "POST", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "POST", Context, Input>; }>;
|
|
32
|
+
readonly 'propfind': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "PROPFIND", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "PROPFIND", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "PROPFIND", Context, Input>; }>;
|
|
33
|
+
readonly 'proppatch': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "PROPPATCH", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "PROPPATCH", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "PROPPATCH", Context, Input>; }>;
|
|
34
|
+
readonly 'purge': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "PURGE", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "PURGE", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "PURGE", Context, Input>; }>;
|
|
35
|
+
readonly 'put': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "PUT", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "PUT", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "PUT", Context, Input>; }>;
|
|
36
|
+
readonly 'rebind': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "REBIND", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "REBIND", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "REBIND", Context, Input>; }>;
|
|
37
|
+
readonly 'report': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "REPORT", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "REPORT", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "REPORT", Context, Input>; }>;
|
|
38
|
+
readonly 'search': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "SEARCH", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "SEARCH", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "SEARCH", Context, Input>; }>;
|
|
39
|
+
readonly 'source': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "SOURCE", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "SOURCE", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "SOURCE", Context, Input>; }>;
|
|
40
|
+
readonly 'subscribe': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "SUBSCRIBE", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "SUBSCRIBE", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "SUBSCRIBE", Context, Input>; }>;
|
|
41
|
+
readonly 'trace': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "TRACE", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "TRACE", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "TRACE", Context, Input>; }>;
|
|
42
|
+
readonly 'unbind': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "UNBIND", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "UNBIND", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "UNBIND", Context, Input>; }>;
|
|
43
|
+
readonly 'unlink': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "UNLINK", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "UNLINK", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "UNLINK", Context, Input>; }>;
|
|
44
|
+
readonly 'unlock': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "UNLOCK", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "UNLOCK", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "UNLOCK", Context, Input>; }>;
|
|
45
|
+
readonly 'unsubscribe': <Result, Path extends `/${string}`, Input extends z.ZodType<any, z.ZodTypeDef, any> = never>(path: Path, route: Omit<Route<Result, Path, "UNSUBSCRIBE", Context, Input>, "method">) => Router<Context, Path extends keyof Routes ? NoEmpty<Pick<Routes, Path>> | { [key in Path]: Route<Result, Path, "UNSUBSCRIBE", Context, Input>; } : Routes & { [key_1 in Path]: Route<Result, Path, "UNSUBSCRIBE", Context, Input>; }>;
|
|
46
46
|
private constructor();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
merge<Prefix extends string, NewRoutes extends RoutesInit<Context>>(prefix: NormalizePath<Prefix>, router: Router<Context, NewRoutes>): Router<Context, Routes & { [Path in Extract<keyof NewRoutes, string> as `/${Prefix}${Path}`]: Values<{ [M in NewRoutes[Path]["method"]]: Omit<Extract<NewRoutes[Path], {
|
|
48
|
+
method: M;
|
|
49
|
+
}>, "method" | "path"> & {
|
|
50
|
+
path: `/${Prefix}${Path}`;
|
|
51
|
+
method: M;
|
|
52
|
+
}; }>; }>;
|
|
53
|
+
toFindMyWay(server: ServerConfig<Context>): Instance<fmw.HTTPVersion.V1>;
|
|
54
|
+
_copy<NewRoutes extends RoutesInit<Context>>(routes: NewRoutes): Router<Context, NewRoutes>;
|
|
55
|
+
private make;
|
|
50
56
|
}
|
|
51
57
|
/**
|
|
52
58
|
* @deprecated Please use Router#create instead
|
|
@@ -12,6 +12,7 @@ export declare function getLastEntryInMultiHeaderValue(headerValue: string | str
|
|
|
12
12
|
declare type RemoveEndSlashes<T extends string> = T extends `${infer U}/` ? U : T;
|
|
13
13
|
declare type AddStartSlashes<T extends string> = T extends `/${infer U}` ? `/${U}` : `/${T}`;
|
|
14
14
|
export declare type NormalizePath<T extends string> = AddStartSlashes<RemoveEndSlashes<T>>;
|
|
15
|
-
export declare
|
|
15
|
+
export declare type Values<T> = T[keyof T];
|
|
16
|
+
export declare type NoEmpty<T> = [keyof T] extends [never] ? never : T;
|
|
16
17
|
export declare function getInput(req: KaitoRequest): Promise<unknown>;
|
|
17
18
|
export {};
|
|
@@ -169,19 +169,6 @@ function getLastEntryInMultiHeaderValue(headerValue) {
|
|
|
169
169
|
var lastIndex = normalized.lastIndexOf(',');
|
|
170
170
|
return lastIndex === -1 ? normalized.trim() : normalized.slice(lastIndex + 1).trim();
|
|
171
171
|
}
|
|
172
|
-
function normalizePath(path) {
|
|
173
|
-
var result = path;
|
|
174
|
-
|
|
175
|
-
if (!result.startsWith('/')) {
|
|
176
|
-
result = "/".concat(result);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (result.endsWith('/')) {
|
|
180
|
-
result = result.slice(-1);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
172
|
function getInput(_x) {
|
|
186
173
|
return _getInput.apply(this, arguments);
|
|
187
174
|
}
|
|
@@ -291,11 +278,11 @@ class KaitoResponse {
|
|
|
291
278
|
}
|
|
292
279
|
|
|
293
280
|
class Router {
|
|
294
|
-
static
|
|
281
|
+
static create() {
|
|
295
282
|
return new Router({});
|
|
296
283
|
}
|
|
297
284
|
|
|
298
|
-
static
|
|
285
|
+
static handle(server, options) {
|
|
299
286
|
return _asyncToGenerator(function* () {
|
|
300
287
|
try {
|
|
301
288
|
var _options$route$input$, _options$route$input;
|
|
@@ -345,7 +332,7 @@ class Router {
|
|
|
345
332
|
})();
|
|
346
333
|
}
|
|
347
334
|
|
|
348
|
-
|
|
335
|
+
constructor(routes) {
|
|
349
336
|
_defineProperty(this, 'acl', this.make('ACL'));
|
|
350
337
|
|
|
351
338
|
_defineProperty(this, 'bind', this.make('BIND'));
|
|
@@ -366,7 +353,7 @@ class Router {
|
|
|
366
353
|
|
|
367
354
|
_defineProperty(this, 'lock', this.make('LOCK'));
|
|
368
355
|
|
|
369
|
-
_defineProperty(this, '
|
|
356
|
+
_defineProperty(this, 'm_search', this.make('M-SEARCH'));
|
|
370
357
|
|
|
371
358
|
_defineProperty(this, 'mkactivity', this.make('MKACTIVITY'));
|
|
372
359
|
|
|
@@ -415,15 +402,18 @@ class Router {
|
|
|
415
402
|
this.routes = routes;
|
|
416
403
|
}
|
|
417
404
|
|
|
418
|
-
|
|
405
|
+
merge(prefix, router) {
|
|
419
406
|
var newRoutes = Object.fromEntries(Object.entries(router.routes).map(_ref => {
|
|
420
407
|
var [k, v] = _ref;
|
|
421
408
|
return ["".concat(prefix).concat(k), v];
|
|
422
409
|
}));
|
|
423
|
-
|
|
410
|
+
|
|
411
|
+
var merged = _objectSpread2(_objectSpread2({}, this.routes), newRoutes);
|
|
412
|
+
|
|
413
|
+
return this._copy(merged);
|
|
424
414
|
}
|
|
425
415
|
|
|
426
|
-
|
|
416
|
+
toFindMyWay(server) {
|
|
427
417
|
var _this = this;
|
|
428
418
|
|
|
429
419
|
var instance = fmw__default["default"]({
|
|
@@ -440,7 +430,8 @@ class Router {
|
|
|
440
430
|
});
|
|
441
431
|
}
|
|
442
432
|
|
|
443
|
-
});
|
|
433
|
+
});
|
|
434
|
+
var paths = Object.keys(this.routes);
|
|
444
435
|
|
|
445
436
|
var _loop = function _loop(path) {
|
|
446
437
|
var route = _this.routes[path];
|
|
@@ -462,22 +453,31 @@ class Router {
|
|
|
462
453
|
}());
|
|
463
454
|
};
|
|
464
455
|
|
|
465
|
-
for (var path
|
|
456
|
+
for (var path of paths) {
|
|
466
457
|
_loop(path);
|
|
467
458
|
}
|
|
468
459
|
|
|
469
460
|
return instance;
|
|
470
461
|
}
|
|
471
462
|
|
|
472
|
-
|
|
463
|
+
_copy(routes) {
|
|
464
|
+
return new Router(routes);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
make(method) {
|
|
473
468
|
return (path, route) => {
|
|
474
|
-
var
|
|
469
|
+
var addedRoute = _objectSpread2(_objectSpread2({}, route), {}, {
|
|
475
470
|
method
|
|
471
|
+
}); // `as unknown` is required because otherwise
|
|
472
|
+
// this type just gets massive and too slow,
|
|
473
|
+
// so we have to write it out specifically
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
var merged = _objectSpread2(_objectSpread2({}, this.routes), {}, {
|
|
477
|
+
[path]: addedRoute
|
|
476
478
|
});
|
|
477
479
|
|
|
478
|
-
return
|
|
479
|
-
[path]: mergedRoute
|
|
480
|
-
}));
|
|
480
|
+
return this._copy(merged);
|
|
481
481
|
};
|
|
482
482
|
}
|
|
483
483
|
|
|
@@ -499,4 +499,3 @@ exports.createRouter = createRouter;
|
|
|
499
499
|
exports.createServer = createServer;
|
|
500
500
|
exports.getInput = getInput;
|
|
501
501
|
exports.getLastEntryInMultiHeaderValue = getLastEntryInMultiHeaderValue;
|
|
502
|
-
exports.normalizePath = normalizePath;
|
|
@@ -169,19 +169,6 @@ function getLastEntryInMultiHeaderValue(headerValue) {
|
|
|
169
169
|
var lastIndex = normalized.lastIndexOf(',');
|
|
170
170
|
return lastIndex === -1 ? normalized.trim() : normalized.slice(lastIndex + 1).trim();
|
|
171
171
|
}
|
|
172
|
-
function normalizePath(path) {
|
|
173
|
-
var result = path;
|
|
174
|
-
|
|
175
|
-
if (!result.startsWith('/')) {
|
|
176
|
-
result = "/".concat(result);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (result.endsWith('/')) {
|
|
180
|
-
result = result.slice(-1);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
172
|
function getInput(_x) {
|
|
186
173
|
return _getInput.apply(this, arguments);
|
|
187
174
|
}
|
|
@@ -291,11 +278,11 @@ class KaitoResponse {
|
|
|
291
278
|
}
|
|
292
279
|
|
|
293
280
|
class Router {
|
|
294
|
-
static
|
|
281
|
+
static create() {
|
|
295
282
|
return new Router({});
|
|
296
283
|
}
|
|
297
284
|
|
|
298
|
-
static
|
|
285
|
+
static handle(server, options) {
|
|
299
286
|
return _asyncToGenerator(function* () {
|
|
300
287
|
try {
|
|
301
288
|
var _options$route$input$, _options$route$input;
|
|
@@ -345,7 +332,7 @@ class Router {
|
|
|
345
332
|
})();
|
|
346
333
|
}
|
|
347
334
|
|
|
348
|
-
|
|
335
|
+
constructor(routes) {
|
|
349
336
|
_defineProperty(this, 'acl', this.make('ACL'));
|
|
350
337
|
|
|
351
338
|
_defineProperty(this, 'bind', this.make('BIND'));
|
|
@@ -366,7 +353,7 @@ class Router {
|
|
|
366
353
|
|
|
367
354
|
_defineProperty(this, 'lock', this.make('LOCK'));
|
|
368
355
|
|
|
369
|
-
_defineProperty(this, '
|
|
356
|
+
_defineProperty(this, 'm_search', this.make('M-SEARCH'));
|
|
370
357
|
|
|
371
358
|
_defineProperty(this, 'mkactivity', this.make('MKACTIVITY'));
|
|
372
359
|
|
|
@@ -415,15 +402,18 @@ class Router {
|
|
|
415
402
|
this.routes = routes;
|
|
416
403
|
}
|
|
417
404
|
|
|
418
|
-
|
|
405
|
+
merge(prefix, router) {
|
|
419
406
|
var newRoutes = Object.fromEntries(Object.entries(router.routes).map(_ref => {
|
|
420
407
|
var [k, v] = _ref;
|
|
421
408
|
return ["".concat(prefix).concat(k), v];
|
|
422
409
|
}));
|
|
423
|
-
|
|
410
|
+
|
|
411
|
+
var merged = _objectSpread2(_objectSpread2({}, this.routes), newRoutes);
|
|
412
|
+
|
|
413
|
+
return this._copy(merged);
|
|
424
414
|
}
|
|
425
415
|
|
|
426
|
-
|
|
416
|
+
toFindMyWay(server) {
|
|
427
417
|
var _this = this;
|
|
428
418
|
|
|
429
419
|
var instance = fmw__default["default"]({
|
|
@@ -440,7 +430,8 @@ class Router {
|
|
|
440
430
|
});
|
|
441
431
|
}
|
|
442
432
|
|
|
443
|
-
});
|
|
433
|
+
});
|
|
434
|
+
var paths = Object.keys(this.routes);
|
|
444
435
|
|
|
445
436
|
var _loop = function _loop(path) {
|
|
446
437
|
var route = _this.routes[path];
|
|
@@ -462,22 +453,31 @@ class Router {
|
|
|
462
453
|
}());
|
|
463
454
|
};
|
|
464
455
|
|
|
465
|
-
for (var path
|
|
456
|
+
for (var path of paths) {
|
|
466
457
|
_loop(path);
|
|
467
458
|
}
|
|
468
459
|
|
|
469
460
|
return instance;
|
|
470
461
|
}
|
|
471
462
|
|
|
472
|
-
|
|
463
|
+
_copy(routes) {
|
|
464
|
+
return new Router(routes);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
make(method) {
|
|
473
468
|
return (path, route) => {
|
|
474
|
-
var
|
|
469
|
+
var addedRoute = _objectSpread2(_objectSpread2({}, route), {}, {
|
|
475
470
|
method
|
|
471
|
+
}); // `as unknown` is required because otherwise
|
|
472
|
+
// this type just gets massive and too slow,
|
|
473
|
+
// so we have to write it out specifically
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
var merged = _objectSpread2(_objectSpread2({}, this.routes), {}, {
|
|
477
|
+
[path]: addedRoute
|
|
476
478
|
});
|
|
477
479
|
|
|
478
|
-
return
|
|
479
|
-
[path]: mergedRoute
|
|
480
|
-
}));
|
|
480
|
+
return this._copy(merged);
|
|
481
481
|
};
|
|
482
482
|
}
|
|
483
483
|
|
|
@@ -499,4 +499,3 @@ exports.createRouter = createRouter;
|
|
|
499
499
|
exports.createServer = createServer;
|
|
500
500
|
exports.getInput = getInput;
|
|
501
501
|
exports.getLastEntryInMultiHeaderValue = getLastEntryInMultiHeaderValue;
|
|
502
|
-
exports.normalizePath = normalizePath;
|
|
@@ -141,19 +141,6 @@ function getLastEntryInMultiHeaderValue(headerValue) {
|
|
|
141
141
|
var lastIndex = normalized.lastIndexOf(',');
|
|
142
142
|
return lastIndex === -1 ? normalized.trim() : normalized.slice(lastIndex + 1).trim();
|
|
143
143
|
}
|
|
144
|
-
function normalizePath(path) {
|
|
145
|
-
var result = path;
|
|
146
|
-
|
|
147
|
-
if (!result.startsWith('/')) {
|
|
148
|
-
result = "/".concat(result);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (result.endsWith('/')) {
|
|
152
|
-
result = result.slice(-1);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
144
|
function getInput(_x) {
|
|
158
145
|
return _getInput.apply(this, arguments);
|
|
159
146
|
}
|
|
@@ -263,11 +250,11 @@ class KaitoResponse {
|
|
|
263
250
|
}
|
|
264
251
|
|
|
265
252
|
class Router {
|
|
266
|
-
static
|
|
253
|
+
static create() {
|
|
267
254
|
return new Router({});
|
|
268
255
|
}
|
|
269
256
|
|
|
270
|
-
static
|
|
257
|
+
static handle(server, options) {
|
|
271
258
|
return _asyncToGenerator(function* () {
|
|
272
259
|
try {
|
|
273
260
|
var _options$route$input$, _options$route$input;
|
|
@@ -317,7 +304,7 @@ class Router {
|
|
|
317
304
|
})();
|
|
318
305
|
}
|
|
319
306
|
|
|
320
|
-
|
|
307
|
+
constructor(routes) {
|
|
321
308
|
_defineProperty(this, 'acl', this.make('ACL'));
|
|
322
309
|
|
|
323
310
|
_defineProperty(this, 'bind', this.make('BIND'));
|
|
@@ -338,7 +325,7 @@ class Router {
|
|
|
338
325
|
|
|
339
326
|
_defineProperty(this, 'lock', this.make('LOCK'));
|
|
340
327
|
|
|
341
|
-
_defineProperty(this, '
|
|
328
|
+
_defineProperty(this, 'm_search', this.make('M-SEARCH'));
|
|
342
329
|
|
|
343
330
|
_defineProperty(this, 'mkactivity', this.make('MKACTIVITY'));
|
|
344
331
|
|
|
@@ -387,15 +374,18 @@ class Router {
|
|
|
387
374
|
this.routes = routes;
|
|
388
375
|
}
|
|
389
376
|
|
|
390
|
-
|
|
377
|
+
merge(prefix, router) {
|
|
391
378
|
var newRoutes = Object.fromEntries(Object.entries(router.routes).map(_ref => {
|
|
392
379
|
var [k, v] = _ref;
|
|
393
380
|
return ["".concat(prefix).concat(k), v];
|
|
394
381
|
}));
|
|
395
|
-
|
|
382
|
+
|
|
383
|
+
var merged = _objectSpread2(_objectSpread2({}, this.routes), newRoutes);
|
|
384
|
+
|
|
385
|
+
return this._copy(merged);
|
|
396
386
|
}
|
|
397
387
|
|
|
398
|
-
|
|
388
|
+
toFindMyWay(server) {
|
|
399
389
|
var _this = this;
|
|
400
390
|
|
|
401
391
|
var instance = fmw({
|
|
@@ -412,7 +402,8 @@ class Router {
|
|
|
412
402
|
});
|
|
413
403
|
}
|
|
414
404
|
|
|
415
|
-
});
|
|
405
|
+
});
|
|
406
|
+
var paths = Object.keys(this.routes);
|
|
416
407
|
|
|
417
408
|
var _loop = function _loop(path) {
|
|
418
409
|
var route = _this.routes[path];
|
|
@@ -434,22 +425,31 @@ class Router {
|
|
|
434
425
|
}());
|
|
435
426
|
};
|
|
436
427
|
|
|
437
|
-
for (var path
|
|
428
|
+
for (var path of paths) {
|
|
438
429
|
_loop(path);
|
|
439
430
|
}
|
|
440
431
|
|
|
441
432
|
return instance;
|
|
442
433
|
}
|
|
443
434
|
|
|
444
|
-
|
|
435
|
+
_copy(routes) {
|
|
436
|
+
return new Router(routes);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
make(method) {
|
|
445
440
|
return (path, route) => {
|
|
446
|
-
var
|
|
441
|
+
var addedRoute = _objectSpread2(_objectSpread2({}, route), {}, {
|
|
447
442
|
method
|
|
443
|
+
}); // `as unknown` is required because otherwise
|
|
444
|
+
// this type just gets massive and too slow,
|
|
445
|
+
// so we have to write it out specifically
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
var merged = _objectSpread2(_objectSpread2({}, this.routes), {}, {
|
|
449
|
+
[path]: addedRoute
|
|
448
450
|
});
|
|
449
451
|
|
|
450
|
-
return
|
|
451
|
-
[path]: mergedRoute
|
|
452
|
-
}));
|
|
452
|
+
return this._copy(merged);
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
455
|
|
|
@@ -460,4 +460,4 @@ class Router {
|
|
|
460
460
|
|
|
461
461
|
var createRouter = Router.create;
|
|
462
462
|
|
|
463
|
-
export { KaitoError, KaitoRequest, KaitoResponse, Router, WrappedError, createFMWServer, createGetContext, createRouter, createServer, getInput, getLastEntryInMultiHeaderValue
|
|
463
|
+
export { KaitoError, KaitoRequest, KaitoResponse, Router, WrappedError, createFMWServer, createGetContext, createRouter, createServer, getInput, getLastEntryInMultiHeaderValue };
|