@kaito-http/core 2.0.0 → 2.0.1
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.
|
@@ -32,7 +32,9 @@ export declare class Router<Ctx, Procs extends ProcsInit<Ctx>> {
|
|
|
32
32
|
constructor(procs: Procs);
|
|
33
33
|
getProcs(): Procs;
|
|
34
34
|
private readonly create;
|
|
35
|
-
readonly merge: <NewCtx
|
|
35
|
+
readonly merge: <Prefix extends string, NewCtx, NewProcs extends ProcsInit<NewCtx>>(prefix: Prefix, router: Router<NewCtx, NewProcs>) => Router<NewCtx & Ctx, Procs & { [Key in `${Prefix}${Extract<keyof NewProcs, string>}`]: Omit<NewProcs[Key extends `${Prefix}${infer Rest}` ? Rest : never], "name"> & {
|
|
36
|
+
name: Key;
|
|
37
|
+
}; }>;
|
|
36
38
|
readonly get: <Name extends string, Result, Input extends z.ZodTypeAny>(name: Name, proc: Readonly<{
|
|
37
39
|
input?: Input | undefined;
|
|
38
40
|
run(arg: ContextWithInput<Ctx, Input extends z.ZodTypeAny ? z.TypeOf<Input> : undefined>): Promise<Result>;
|
|
@@ -120,7 +120,20 @@ class Router {
|
|
|
120
120
|
}));
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
-
_defineProperty(this, "merge", router =>
|
|
123
|
+
_defineProperty(this, "merge", (prefix, router) => {
|
|
124
|
+
var newProcs = Object.entries(router.getProcs()).reduce((all, entry) => {
|
|
125
|
+
var [name, proc] = entry;
|
|
126
|
+
return _objectSpread2(_objectSpread2({}, all), {}, {
|
|
127
|
+
["".concat(prefix).concat(name)]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
128
|
+
name: "".concat(prefix).concat(name)
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}, {});
|
|
132
|
+
|
|
133
|
+
var mergedProcs = _objectSpread2(_objectSpread2({}, this.procs), newProcs);
|
|
134
|
+
|
|
135
|
+
return new Router(mergedProcs);
|
|
136
|
+
});
|
|
124
137
|
|
|
125
138
|
_defineProperty(this, "get", this.create(exports.Method.GET));
|
|
126
139
|
|
|
@@ -120,7 +120,20 @@ class Router {
|
|
|
120
120
|
}));
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
-
_defineProperty(this, "merge", router =>
|
|
123
|
+
_defineProperty(this, "merge", (prefix, router) => {
|
|
124
|
+
var newProcs = Object.entries(router.getProcs()).reduce((all, entry) => {
|
|
125
|
+
var [name, proc] = entry;
|
|
126
|
+
return _objectSpread2(_objectSpread2({}, all), {}, {
|
|
127
|
+
["".concat(prefix).concat(name)]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
128
|
+
name: "".concat(prefix).concat(name)
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}, {});
|
|
132
|
+
|
|
133
|
+
var mergedProcs = _objectSpread2(_objectSpread2({}, this.procs), newProcs);
|
|
134
|
+
|
|
135
|
+
return new Router(mergedProcs);
|
|
136
|
+
});
|
|
124
137
|
|
|
125
138
|
_defineProperty(this, "get", this.create(exports.Method.GET));
|
|
126
139
|
|
|
@@ -112,7 +112,20 @@ class Router {
|
|
|
112
112
|
}));
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
_defineProperty(this, "merge", router =>
|
|
115
|
+
_defineProperty(this, "merge", (prefix, router) => {
|
|
116
|
+
var newProcs = Object.entries(router.getProcs()).reduce((all, entry) => {
|
|
117
|
+
var [name, proc] = entry;
|
|
118
|
+
return _objectSpread2(_objectSpread2({}, all), {}, {
|
|
119
|
+
["".concat(prefix).concat(name)]: _objectSpread2(_objectSpread2({}, proc), {}, {
|
|
120
|
+
name: "".concat(prefix).concat(name)
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}, {});
|
|
124
|
+
|
|
125
|
+
var mergedProcs = _objectSpread2(_objectSpread2({}, this.procs), newProcs);
|
|
126
|
+
|
|
127
|
+
return new Router(mergedProcs);
|
|
128
|
+
});
|
|
116
129
|
|
|
117
130
|
_defineProperty(this, "get", this.create(Method.GET));
|
|
118
131
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaito-http/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Functional HTTP Framework for TypeScript",
|
|
5
|
-
"repository":
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/kaito-http/kaito.git"
|
|
8
|
-
},
|
|
5
|
+
"repository": "https://github.com/kaito-http/kaito",
|
|
9
6
|
"author": "Alistair Smith <hi@alistair.sh>",
|
|
10
7
|
"license": "MIT",
|
|
11
8
|
"main": "dist/kaito-http-core.cjs.js",
|
|
@@ -30,8 +27,14 @@
|
|
|
30
27
|
"bugs": {
|
|
31
28
|
"url": "https://github.com/kaito-http/kaito/issues"
|
|
32
29
|
},
|
|
33
|
-
"homepage": "https://github.com/kaito-http/kaito
|
|
30
|
+
"homepage": "https://github.com/kaito-http/kaito",
|
|
34
31
|
"peerDependencies": {
|
|
35
32
|
"zod": "*"
|
|
36
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"typescript",
|
|
36
|
+
"fastify",
|
|
37
|
+
"http",
|
|
38
|
+
"framework"
|
|
39
|
+
]
|
|
37
40
|
}
|