@fncts/http 0.0.0 → 0.0.2
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.
- package/ResponseError.d.ts +2 -2
- package/Route/api.d.ts +44 -3
- package/Route/definition.d.ts +4 -0
- package/Router/api.d.ts +16 -2
- package/_cjs/Route/api.cjs +42 -3
- package/_cjs/Route/api.cjs.map +1 -1
- package/_cjs/Route/definition.cjs +4 -0
- package/_cjs/Route/definition.cjs.map +1 -1
- package/_cjs/Router/api.cjs +20 -5
- package/_cjs/Router/api.cjs.map +1 -1
- package/_cjs/ServerRequest/internal.cjs +7 -6
- package/_cjs/ServerRequest/internal.cjs.map +1 -1
- package/_mjs/Route/api.mjs +40 -1
- package/_mjs/Route/api.mjs.map +1 -1
- package/_mjs/Route/definition.mjs +4 -0
- package/_mjs/Route/definition.mjs.map +1 -1
- package/_mjs/Router/api.mjs +17 -2
- package/_mjs/Router/api.mjs.map +1 -1
- package/_mjs/ServerRequest/internal.mjs +7 -6
- package/_mjs/ServerRequest/internal.mjs.map +1 -1
- package/_src/ResponseError.ts +2 -2
- package/_src/Route/api.ts +49 -3
- package/_src/Route/definition.ts +4 -0
- package/_src/Router/api.ts +28 -2
- package/_src/ServerRequest/internal.ts +1 -0
- package/package.json +5 -5
package/ResponseError.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerRequest } from "@fncts/http/ServerRequest";
|
|
2
|
-
import { ServerResponse } from "@fncts/http/ServerResponse";
|
|
1
|
+
import type { ServerRequest } from "@fncts/http/ServerRequest";
|
|
2
|
+
import type { ServerResponse } from "@fncts/http/ServerResponse";
|
|
3
3
|
export declare const ResponseErrorTypeId: unique symbol;
|
|
4
4
|
export type ResponseErrorTypeId = typeof ResponseErrorTypeId;
|
|
5
5
|
export declare class ResponseError extends Error {
|
package/Route/api.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { IO } from "@fncts/io/IO";
|
|
|
3
3
|
import { ParseFailure } from "@fncts/schema/ParseFailure";
|
|
4
4
|
import { Maybe } from "@fncts/base/data/Maybe/definition";
|
|
5
5
|
import type { Method } from "../Method.js";
|
|
6
|
-
import type { PathInput
|
|
7
|
-
import { RouteContext } from "./definition.js";
|
|
6
|
+
import type { PathInput } from "./definition.js";
|
|
7
|
+
import { Route, RouteContext } from "./definition.js";
|
|
8
8
|
/**
|
|
9
9
|
* @tsplus static fncts.http.RouteContextOps params
|
|
10
10
|
* @tsplus location "@fncts/http/Route/api"
|
|
@@ -34,4 +34,45 @@ export declare function schemaSearchParams<A>(schema: Schema<A>): IO<RouteContex
|
|
|
34
34
|
* @tsplus static fncts.http.RouteOps __call
|
|
35
35
|
* @tsplus location "@fncts/http/Route/api"
|
|
36
36
|
*/
|
|
37
|
-
export declare function make<R, E>(method: Method, path: PathInput, handler: Route.Handler<R, E>, prefix?: Maybe<string>): Route<R, E>;
|
|
37
|
+
export declare function make<R, E>(method: Method | "*", path: PathInput, handler: Route.Handler<R, E>, prefix?: Maybe<string>): Route<R, E>;
|
|
38
|
+
export declare function route(method: Method | "*"): <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
39
|
+
/**
|
|
40
|
+
* @tsplus static fncts.http.RouteOps get
|
|
41
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
42
|
+
*/
|
|
43
|
+
export declare const get: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
44
|
+
/**
|
|
45
|
+
* @tsplus static fncts.http.RouteOps post
|
|
46
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
47
|
+
*/
|
|
48
|
+
export declare const post: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
49
|
+
/**
|
|
50
|
+
* @tsplus static fncts.http.RouteOps put
|
|
51
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
52
|
+
*/
|
|
53
|
+
export declare const put: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
54
|
+
/**
|
|
55
|
+
* @tsplus static fncts.http.RouteOps patch
|
|
56
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
57
|
+
*/
|
|
58
|
+
export declare const patch: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
59
|
+
/**
|
|
60
|
+
* @tsplus static fncts.http.RouteOps del
|
|
61
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
62
|
+
*/
|
|
63
|
+
export declare const del: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
64
|
+
/**
|
|
65
|
+
* @tsplus static fncts.http.RouteOps head
|
|
66
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
67
|
+
*/
|
|
68
|
+
export declare const head: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
69
|
+
/**
|
|
70
|
+
* @tsplus static fncts.http.RouteOps options
|
|
71
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
72
|
+
*/
|
|
73
|
+
export declare const options: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
|
74
|
+
/**
|
|
75
|
+
* @tsplus static fncts.http.RouteOps all
|
|
76
|
+
* @tsplus location "@fncts/http/Route/api"
|
|
77
|
+
*/
|
|
78
|
+
export declare const all: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E>;
|
package/Route/definition.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import type { ServerResponse } from "../ServerResponse.js";
|
|
|
6
6
|
export declare const RouteTypeId: unique symbol;
|
|
7
7
|
export type RouteTypeId = typeof RouteTypeId;
|
|
8
8
|
export type PathInput = `/${string}` | "*";
|
|
9
|
+
/**
|
|
10
|
+
* @tsplus type fncts.http.Route
|
|
11
|
+
* @tsplus companion fncts.http.RouteOps
|
|
12
|
+
*/
|
|
9
13
|
export declare abstract class Route<R, E> {
|
|
10
14
|
readonly [RouteTypeId]: RouteTypeId;
|
|
11
15
|
abstract readonly method: Method | "*";
|
package/Router/api.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Tag } from "@fncts/base/data/Tag/definition";
|
|
|
4
4
|
import type { HttpApp } from "../HttpApp.js";
|
|
5
5
|
import type { Method } from "../Method.js";
|
|
6
6
|
import type { PathInput, Route } from "../Route.js";
|
|
7
|
-
import
|
|
7
|
+
import { Router } from "./definition.js";
|
|
8
8
|
/**
|
|
9
9
|
* @tsplus static fncts.http.RouterOps empty
|
|
10
10
|
* @tsplus location "@fncts/http/Router/api"
|
|
@@ -63,7 +63,21 @@ export declare function use<R, E, R1, E1>(f: (self: Route.Handler<R, E>) => Http
|
|
|
63
63
|
* @tsplus static fncts.http.RouterOps from
|
|
64
64
|
* @tsplus location "@fncts/http/Router/api"
|
|
65
65
|
*/
|
|
66
|
-
export declare function from<R extends Route<any, any>>(routes: Iterable<R>): Router<R extends Route<infer Env, infer _> ? Env : never, R extends Route<infer _, infer E> ? E : never>;
|
|
66
|
+
export declare function from<R extends Route<any, any>>(routes: Iterable<R>): Router<R extends Route<infer Env, infer _> ? Router.ExcludeProvided<Env> : never, R extends Route<infer _, infer E> ? E : never>;
|
|
67
|
+
/**
|
|
68
|
+
* @tsplus static fncts.http.RouterOps routes
|
|
69
|
+
* @tsplus location "@fncts/http/Router/api"
|
|
70
|
+
*/
|
|
71
|
+
export declare function routes<Rs extends Array<Route<any, any>>>(...routes: Rs): Router<{
|
|
72
|
+
[K in keyof Rs]: Rs[K] extends Route<infer Env, infer _> ? Router.ExcludeProvided<Env> : never;
|
|
73
|
+
}[number], {
|
|
74
|
+
[K in keyof Rs]: Rs[K] extends Route<infer _, infer E> ? E : never;
|
|
75
|
+
}[number]>;
|
|
76
|
+
/**
|
|
77
|
+
* @tsplus pipeable fncts.http.Router append
|
|
78
|
+
* @tsplus location "@fncts/http/Router/api"
|
|
79
|
+
*/
|
|
80
|
+
export declare function append<R1, E1>(route: Route<R1, E1>): <R, E>(self: Router<R, E>) => Router<R | Router.ExcludeProvided<R1>, E | E1>;
|
|
67
81
|
/**
|
|
68
82
|
* @tsplus pipeable fncts.http.Router concat
|
|
69
83
|
* @tsplus location "@fncts/http/Router/api"
|
package/_cjs/Route/api.cjs
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.make =
|
|
7
|
-
exports.
|
|
6
|
+
exports.put = exports.post = exports.patch = exports.params = exports.options = exports.make = exports.head = exports.get = exports.del = exports.all = void 0;
|
|
7
|
+
exports.route = route;
|
|
8
8
|
exports.schemaParams = schemaParams;
|
|
9
9
|
exports.schemaPathParams = schemaPathParams;
|
|
10
10
|
exports.schemaSearchParams = schemaSearchParams;
|
|
@@ -14,10 +14,12 @@ var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require
|
|
|
14
14
|
var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api"));
|
|
15
15
|
var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/Parser/api"));
|
|
16
16
|
var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
|
|
17
|
+
var _definition2 = /*#__PURE__*/require("./definition.cjs");
|
|
17
18
|
var _internal = /*#__PURE__*/require("./internal.cjs");
|
|
18
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
21
|
const fileName_1 = "(@fncts/http) src/Route/api.ts";
|
|
22
|
+
const make = exports.make = make_1;
|
|
21
23
|
/**
|
|
22
24
|
* @tsplus static fncts.http.RouteContextOps params
|
|
23
25
|
*/
|
|
@@ -55,7 +57,44 @@ function schemaSearchParams(schema) {
|
|
|
55
57
|
/**
|
|
56
58
|
* @tsplus static fncts.http.RouteOps __call
|
|
57
59
|
*/
|
|
58
|
-
function
|
|
60
|
+
function make_1(method, path, handler, prefix = tsplus_module_5.nothing(fileName_1 + ":50:34")) {
|
|
59
61
|
return new _internal.RouteImpl(method, path, handler, prefix);
|
|
60
62
|
}
|
|
63
|
+
function route(method) {
|
|
64
|
+
return (path, handler) => {
|
|
65
|
+
return make_1(method, path, handler);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @tsplus static fncts.http.RouteOps get
|
|
70
|
+
*/
|
|
71
|
+
const get = exports.get = /*#__PURE__*/route("GET");
|
|
72
|
+
/**
|
|
73
|
+
* @tsplus static fncts.http.RouteOps post
|
|
74
|
+
*/
|
|
75
|
+
const post = exports.post = /*#__PURE__*/route("POST");
|
|
76
|
+
/**
|
|
77
|
+
* @tsplus static fncts.http.RouteOps put
|
|
78
|
+
*/
|
|
79
|
+
const put = exports.put = /*#__PURE__*/route("PUT");
|
|
80
|
+
/**
|
|
81
|
+
* @tsplus static fncts.http.RouteOps patch
|
|
82
|
+
*/
|
|
83
|
+
const patch = exports.patch = /*#__PURE__*/route("PATCH");
|
|
84
|
+
/**
|
|
85
|
+
* @tsplus static fncts.http.RouteOps del
|
|
86
|
+
*/
|
|
87
|
+
const del = exports.del = /*#__PURE__*/route("DELETE");
|
|
88
|
+
/**
|
|
89
|
+
* @tsplus static fncts.http.RouteOps head
|
|
90
|
+
*/
|
|
91
|
+
const head = exports.head = /*#__PURE__*/route("HEAD");
|
|
92
|
+
/**
|
|
93
|
+
* @tsplus static fncts.http.RouteOps options
|
|
94
|
+
*/
|
|
95
|
+
const options = exports.options = /*#__PURE__*/route("OPTIONS");
|
|
96
|
+
/**
|
|
97
|
+
* @tsplus static fncts.http.RouteOps all
|
|
98
|
+
*/
|
|
99
|
+
const all = exports.all = /*#__PURE__*/route("*");
|
|
61
100
|
//# sourceMappingURL=api.cjs.map
|
package/_cjs/Route/api.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.cjs","names":["
|
|
1
|
+
{"version":3,"file":"api.cjs","names":["_definition2","require","_internal","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","make","exports","make_1","params_1","tsplus_module_3","map","routeContext","params","fileName_1","tsplus_module_2","service","tsplus_module_1","RouteContextTag","searchParams_1","searchParams","schemaParams","schema","decode","tsplus_module_4","flatMap","schemaPathParams","schemaSearchParams","method","path","handler","prefix","tsplus_module_5","nothing","RouteImpl","route","post","put","patch","del","head","options","all"],"sources":["../../_src/Route/api.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAGA,IAAAA,YAAA,gBAAAC,OAAA;AACA,IAAAC,SAAA,gBAAAD,OAAA;AAA0C,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAM,OAAA,EAAAN,CAAA,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c,OAAA,CAAAd,GAAA,gBAAyE0C,KAAK,CAAC,KAAK,CAAC;AAErG;;;AAGO,MAAMC,IAAI,GAAA7B,OAAA,CAAA6B,IAAA,gBAAyED,KAAK,CAAC,MAAM,CAAC;AAEvG;;;AAGO,MAAME,GAAG,GAAA9B,OAAA,CAAA8B,GAAA,gBAAyEF,KAAK,CAAC,KAAK,CAAC;AAErG;;;AAGO,MAAMG,KAAK,GAAA/B,OAAA,CAAA+B,KAAA,gBAAyEH,KAAK,CAAC,OAAO,CAAC;AAEzG;;;AAGO,MAAMI,GAAG,GAAAhC,OAAA,CAAAgC,GAAA,gBAAyEJ,KAAK,CAAC,QAAQ,CAAC;AAExG;;;AAGO,MAAMK,IAAI,GAAAjC,OAAA,CAAAiC,IAAA,gBAAyEL,KAAK,CAAC,MAAM,CAAC;AAEvG;;;AAGO,MAAMM,OAAO,GAAAlC,OAAA,CAAAkC,OAAA,gBAAyEN,KAAK,CAAC,SAAS,CAAC;AAE7G;;;AAGO,MAAMO,GAAG,GAAAnC,OAAA,CAAAmC,GAAA,gBAAyEP,KAAK,CAAC,GAAG,CAAC"}
|
|
@@ -9,6 +9,10 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
9
9
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const RouteTypeId = exports.RouteTypeId = /*#__PURE__*/Symbol.for("fncts.http.RouteTypeId");
|
|
12
|
+
/**
|
|
13
|
+
* @tsplus type fncts.http.Route
|
|
14
|
+
* @tsplus companion fncts.http.RouteOps
|
|
15
|
+
*/
|
|
12
16
|
class Route {
|
|
13
17
|
constructor() {
|
|
14
18
|
this[_a] = RouteTypeId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.cjs","names":["RouteTypeId","exports","Symbol","for","Route","constructor","_a","RouteContextTypeId","RouteContext","_b","RouteContextTag","tsplus_module_1","makeTag"],"sources":["../../_src/Route/definition.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;AAIO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,gBAAGE,MAAM,CAACC,GAAG,CAAC,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"definition.cjs","names":["RouteTypeId","exports","Symbol","for","Route","constructor","_a","RouteContextTypeId","RouteContext","_b","RouteContextTag","tsplus_module_1","makeTag"],"sources":["../../_src/Route/definition.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;AAIO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,gBAAGE,MAAM,CAACC,GAAG,CAAC,wBAAwB,CAAC;AAK/D;;;;AAIM,MAAgBC,KAAK;EAA3BC,YAAA;IACW,KAAAC,EAAA,CAAa,GAAgBN,WAAW;EAMnD;;AAACC,OAAA,CAAAG,KAAA,GAAAA,KAAA;KANWJ,WAAW;AAYhB,MAAMO,kBAAkB,GAAAN,OAAA,CAAAM,kBAAA,gBAAGL,MAAM,CAACC,GAAG,CAAC,+BAA+B,CAAC;AAG7E;;;;AAIM,MAAgBK,YAAY;EAAlCH,YAAA;IACW,KAAAI,EAAA,CAAoB,GAAuBF,kBAAkB;EAIxE;;AAACN,OAAA,CAAAO,YAAA,GAAAA,YAAA;KAJWD,kBAAkB;AAM9B;;;AAGO,MAAMG,eAAe,GAAAT,OAAA,CAAAS,eAAA,gBAAGC,eAAA,CAAAC,OAAA,EAAmB"}
|
package/_cjs/Router/api.cjs
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.append = append;
|
|
6
7
|
exports.catchAll = catchAll;
|
|
7
8
|
exports.catchAllCause = catchAllCause;
|
|
8
|
-
exports.empty = exports.del = exports.concat = void 0;
|
|
9
|
-
exports.from = from;
|
|
10
|
-
exports.head = exports.get = void 0;
|
|
9
|
+
exports.head = exports.get = exports.from = exports.empty = exports.del = exports.concat = void 0;
|
|
11
10
|
exports.mount = mount;
|
|
12
11
|
exports.prefixAll = exports.post = exports.patch = exports.options = void 0;
|
|
13
12
|
exports.provideService = provideService;
|
|
14
13
|
exports.put = void 0;
|
|
15
14
|
exports.route = route;
|
|
15
|
+
exports.routes = routes;
|
|
16
16
|
exports.use = void 0;
|
|
17
17
|
var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api/empty"));
|
|
18
18
|
var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api"));
|
|
@@ -27,6 +27,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
27
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
28
|
const fileName_1 = "(@fncts/http) src/Router/api.ts";
|
|
29
29
|
const use = exports.use = use_1;
|
|
30
|
+
const from = exports.from = from_1;
|
|
30
31
|
const concat = exports.concat = concat_1;
|
|
31
32
|
const prefixAll = exports.prefixAll = prefixAll_1;
|
|
32
33
|
/**
|
|
@@ -87,9 +88,23 @@ function use_1(f, __tsplusTrace) {
|
|
|
87
88
|
/**
|
|
88
89
|
* @tsplus static fncts.http.RouterOps from
|
|
89
90
|
*/
|
|
90
|
-
function
|
|
91
|
+
function from_1(routes) {
|
|
91
92
|
return new _internal2.RouterInternal(tsplus_module_3.from(routes), tsplus_module_1.empty());
|
|
92
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* @tsplus static fncts.http.RouterOps routes
|
|
96
|
+
*/
|
|
97
|
+
function routes(...routes) {
|
|
98
|
+
return from_1(routes);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @tsplus pipeable fncts.http.Router append
|
|
102
|
+
*/
|
|
103
|
+
function append(route) {
|
|
104
|
+
return self => {
|
|
105
|
+
return new _internal2.RouterInternal(tsplus_module_2.append(route)(self.routes), self.mounts);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
93
108
|
/**
|
|
94
109
|
* @tsplus pipeable fncts.http.Router concat
|
|
95
110
|
*/
|
|
@@ -105,7 +120,7 @@ function removeTrailingSlash(path) {
|
|
|
105
120
|
function prefixAll_1(prefix) {
|
|
106
121
|
return self => {
|
|
107
122
|
prefix = removeTrailingSlash(prefix);
|
|
108
|
-
return new _internal2.RouterInternal(tsplus_module_2.map(route => new _internal.RouteImpl(route.method, route.path === "/" ? prefix : prefix + route.path, route.handler, tsplus_module_5.orElse(() => tsplus_module_4.just(prefix, fileName_1 + ":
|
|
123
|
+
return new _internal2.RouterInternal(tsplus_module_2.map(route => new _internal.RouteImpl(route.method, route.path === "/" ? prefix : prefix + route.path, route.handler, tsplus_module_5.orElse(() => tsplus_module_4.just(prefix, fileName_1 + ":150:60"))(tsplus_module_5.map(_ => prefix + _)(route.prefix))))(self.routes), tsplus_module_2.map(({
|
|
109
124
|
prefix: path,
|
|
110
125
|
httpApp
|
|
111
126
|
}) => ({
|
package/_cjs/Router/api.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.cjs","names":["_internal","require","_internal2","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","use","exports","use_1","concat","concat_1","prefixAll","prefixAll_1","empty","RouterInternal","tsplus_module_1","route","method","path","handler","self","tsplus_module_2","append","RouteImpl","routes","mounts","post","put","patch","del","head","options","f","__tsplusTrace","map","prefix","httpApp","
|
|
1
|
+
{"version":3,"file":"api.cjs","names":["_internal","require","_internal2","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","use","exports","use_1","from","from_1","concat","concat_1","prefixAll","prefixAll_1","empty","RouterInternal","tsplus_module_1","route","method","path","handler","self","tsplus_module_2","append","RouteImpl","routes","mounts","post","put","patch","del","head","options","f","__tsplusTrace","map","prefix","httpApp","tsplus_module_3","that","removeTrailingSlash","endsWith","slice","tsplus_module_5","orElse","tsplus_module_4","just","fileName_1","_","mount","catchAll","tsplus_module_6","catchAllCause","provideService","service","tag","tsplus_module_7","provideSomeService"],"sources":["../../_src/Router/api.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,SAAA,gBAAAC,OAAA;AAIA,IAAAC,UAAA,gBAAAD,OAAA;AAA+C,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAAA,C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AAUgC,cAAcA,CAAIC,OAAU,EAAEC,GAAW,EAAErB,aAAsB;EAC/E,OAAcb,IAAkB,IAC9Bd,KAAA,CAAUa,OAAO,IAAKoC,eAAA,CAAAC,kBAAA,CAA2BH,OAAO,EAAEC,GAAG,EAFNrB,aAAA,EAEjCd,OAAO,CAAiC,EAFPc,aAAA,EAEvDb,IAAI,CAA2D;AACnE"}
|
|
@@ -36,6 +36,7 @@ class ServerRequestImpl extends _definition.ServerRequest {
|
|
|
36
36
|
return tsplus_module_1.fromNullable(this.remoteAddressOverride);
|
|
37
37
|
}
|
|
38
38
|
get headers() {
|
|
39
|
+
// eslint-disable-next-line @0x706b/align-assignments/align-assignments
|
|
39
40
|
this.headersOverride ?? (this.headersOverride = tsplus_module_2.fromHeaders(this.source.headers));
|
|
40
41
|
return this.headersOverride;
|
|
41
42
|
}
|
|
@@ -43,34 +44,34 @@ class ServerRequestImpl extends _definition.ServerRequest {
|
|
|
43
44
|
if (this.textIO) {
|
|
44
45
|
return this.textIO;
|
|
45
46
|
}
|
|
46
|
-
this.textIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.text(), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":
|
|
47
|
+
this.textIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.text(), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":43:38"), fileName_1 + ":46:6")));
|
|
47
48
|
return this.textIO;
|
|
48
49
|
}
|
|
49
50
|
get json() {
|
|
50
|
-
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => JSON.parse(text), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":
|
|
51
|
+
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => JSON.parse(text), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":53:18"), fileName_1 + ":52:29")(this.text);
|
|
51
52
|
}
|
|
52
53
|
get urlParamsBody() {
|
|
53
|
-
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => tsplus_module_7.make(new URLSearchParams(text)), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":
|
|
54
|
+
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => tsplus_module_7.make(new URLSearchParams(text)), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":62:18"), fileName_1 + ":61:29")(this.text);
|
|
54
55
|
}
|
|
55
56
|
get arrayBuffer() {
|
|
56
57
|
if (this.arrayBufferIO) {
|
|
57
58
|
return this.arrayBufferIO;
|
|
58
59
|
}
|
|
59
|
-
this.arrayBufferIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.arrayBuffer(), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":
|
|
60
|
+
this.arrayBufferIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.arrayBuffer(), error => new _RequestError.RequestError(this, "Decode", error), fileName_1 + ":75:45"), fileName_1 + ":78:6")));
|
|
60
61
|
return this.arrayBufferIO;
|
|
61
62
|
}
|
|
62
63
|
get stream() {
|
|
63
64
|
if (this.source.body) {
|
|
64
65
|
return tsplus_module_8.fromReadableStream(() => this.source.body, error => new _RequestError.RequestError(this, "Decode", error));
|
|
65
66
|
} else {
|
|
66
|
-
return tsplus_module_8.failNow(new _RequestError.RequestError(this, "Decode", "cannot create stream from empty body"), fileName_1 + ":
|
|
67
|
+
return tsplus_module_8.failNow(new _RequestError.RequestError(this, "Decode", "cannot create stream from empty body"), fileName_1 + ":87:28");
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
modify(options) {
|
|
70
71
|
return new ServerRequestImpl(this.source, options.url ?? this.url, options.headers ?? this.headers, options.remoteAddress ?? this.remoteAddressOverride);
|
|
71
72
|
}
|
|
72
73
|
get upgrade() {
|
|
73
|
-
return tsplus_module_3.failNow(new _RequestError.RequestError(this, "Decode", "Not an upgradeable ServerRequest"), fileName_1 + ":
|
|
74
|
+
return tsplus_module_3.failNow(new _RequestError.RequestError(this, "Decode", "Not an upgradeable ServerRequest"), fileName_1 + ":105:22");
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
exports.ServerRequestImpl = ServerRequestImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.cjs","names":["_RequestError","require","_UrlParams2","_definition","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ServerRequestImpl","ServerRequest","constructor","source","url","headersOverride","remoteAddressOverride","method","toUpperCase","originalUrl","remoteAddress","tsplus_module_1","fromNullable","headers","tsplus_module_2","fromHeaders","text","textIO","tsplus_module_6","getOrThrow","tsplus_module_5","unsafeRun","tsplus_module_4","memoize","tsplus_module_3","fromPromiseCatch","error","RequestError","fileName_1","json","flatMap","tryCatch","JSON","parse","urlParamsBody","tsplus_module_7","make","URLSearchParams","arrayBuffer","arrayBufferIO","stream","body","tsplus_module_8","fromReadableStream","failNow","modify","options","upgrade","exports"],"sources":["../../_src/ServerRequest/internal.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAIA,IAAAA,aAAA,gBAAAC,OAAA;AACA,IAAAC,WAAA,gBAAAD,OAAA;AACA,IAAAE,WAAA,gBAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA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AAOA,CAAA;IACT,OAAOvB,eAAA,CAAAoB,OAAA,CAAW,IAAIjB,0BAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,kCAAkC,CAAC,EAAAC,UAAA,aAAC;EACzF;;AACDoB,OAAA,CAAAhD,iBAAA,GAAAA,iBAAA"}
|
|
1
|
+
{"version":3,"file":"internal.cjs","names":["_RequestError","require","_UrlParams2","_definition","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ServerRequestImpl","ServerRequest","constructor","source","url","headersOverride","remoteAddressOverride","method","toUpperCase","originalUrl","remoteAddress","tsplus_module_1","fromNullable","headers","tsplus_module_2","fromHeaders","text","textIO","tsplus_module_6","getOrThrow","tsplus_module_5","unsafeRun","tsplus_module_4","memoize","tsplus_module_3","fromPromiseCatch","error","RequestError","fileName_1","json","flatMap","tryCatch","JSON","parse","urlParamsBody","tsplus_module_7","make","URLSearchParams","arrayBuffer","arrayBufferIO","stream","body","tsplus_module_8","fromReadableStream","failNow","modify","options","upgrade","exports"],"sources":["../../_src/ServerRequest/internal.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAIA,IAAAA,aAAA,gBAAAC,OAAA;AACA,IAAAC,WAAA,gBAAAD,OAAA;AACA,IAAAE,WAAA,gBAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAM,OAAA,EAAAN,CAAA,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;EACzF;;AACDoB,OAAA,CAAAhD,iBAAA,GAAAA,iBAAA"}
|
package/_mjs/Route/api.mjs
CHANGED
|
@@ -4,6 +4,8 @@ import * as tsplus_module_2 from "@fncts/io/IO/api/environment";
|
|
|
4
4
|
import * as tsplus_module_3 from "@fncts/io/IO/api";
|
|
5
5
|
import * as tsplus_module_4 from "@fncts/schema/Parser/api";
|
|
6
6
|
import * as tsplus_module_5 from "@fncts/base/data/Maybe/constructors";
|
|
7
|
+
export const make = make_1;
|
|
8
|
+
import { Route } from "./definition.mjs";
|
|
7
9
|
import { RouteImpl } from "./internal.mjs";
|
|
8
10
|
/**
|
|
9
11
|
* @tsplus static fncts.http.RouteContextOps params
|
|
@@ -42,7 +44,44 @@ export function schemaSearchParams(schema) {
|
|
|
42
44
|
/**
|
|
43
45
|
* @tsplus static fncts.http.RouteOps __call
|
|
44
46
|
*/
|
|
45
|
-
|
|
47
|
+
function make_1(method, path, handler, prefix = tsplus_module_5.nothing(fileName_1 + ":50:34")) {
|
|
46
48
|
return new RouteImpl(method, path, handler, prefix);
|
|
47
49
|
}
|
|
50
|
+
export function route(method) {
|
|
51
|
+
return (path, handler) => {
|
|
52
|
+
return make_1(method, path, handler);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @tsplus static fncts.http.RouteOps get
|
|
57
|
+
*/
|
|
58
|
+
export const get = /*#__PURE__*/route("GET");
|
|
59
|
+
/**
|
|
60
|
+
* @tsplus static fncts.http.RouteOps post
|
|
61
|
+
*/
|
|
62
|
+
export const post = /*#__PURE__*/route("POST");
|
|
63
|
+
/**
|
|
64
|
+
* @tsplus static fncts.http.RouteOps put
|
|
65
|
+
*/
|
|
66
|
+
export const put = /*#__PURE__*/route("PUT");
|
|
67
|
+
/**
|
|
68
|
+
* @tsplus static fncts.http.RouteOps patch
|
|
69
|
+
*/
|
|
70
|
+
export const patch = /*#__PURE__*/route("PATCH");
|
|
71
|
+
/**
|
|
72
|
+
* @tsplus static fncts.http.RouteOps del
|
|
73
|
+
*/
|
|
74
|
+
export const del = /*#__PURE__*/route("DELETE");
|
|
75
|
+
/**
|
|
76
|
+
* @tsplus static fncts.http.RouteOps head
|
|
77
|
+
*/
|
|
78
|
+
export const head = /*#__PURE__*/route("HEAD");
|
|
79
|
+
/**
|
|
80
|
+
* @tsplus static fncts.http.RouteOps options
|
|
81
|
+
*/
|
|
82
|
+
export const options = /*#__PURE__*/route("OPTIONS");
|
|
83
|
+
/**
|
|
84
|
+
* @tsplus static fncts.http.RouteOps all
|
|
85
|
+
*/
|
|
86
|
+
export const all = /*#__PURE__*/route("*");
|
|
48
87
|
//# sourceMappingURL=api.mjs.map
|
package/_mjs/Route/api.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":["RouteImpl","params_1","tsplus_module_3","map","routeContext","params","fileName_1","tsplus_module_2","service","tsplus_module_1","RouteContextTag","searchParams_1","searchParams","schemaParams","schema","decode","tsplus_module_4","flatMap","schemaPathParams","schemaSearchParams","
|
|
1
|
+
{"version":3,"file":"api.mjs","names":["make","make_1","Route","RouteImpl","params_1","tsplus_module_3","map","routeContext","params","fileName_1","tsplus_module_2","service","tsplus_module_1","RouteContextTag","searchParams_1","searchParams","schemaParams","schema","decode","tsplus_module_4","flatMap","schemaPathParams","schemaSearchParams","method","path","handler","prefix","tsplus_module_5","nothing","route","get","post","put","patch","del","head","options","all"],"sources":["../../_src/Route/api.ts"],"sourcesContent":[null],"mappings":";;;;;;aA6CgBA,IAAI,GAAAC,MAAA;AA1CpB,SAASC,KAAK,QAAsB,kBAAiB;AACrD,SAASC,SAAS,QAAQ,gBAAe;AAEzC;;;AAGO,MAAMC,QAAA,gBAASC,eAAA,CAAAC,GAAA,CAAkCC,YAAY,IAAKA,YAAY,CAACC,MAAM,EAAAC,UAAA,2BAAtEC,eAAA,CAAAC,OAAA,CAAAC,eAAA,CAAAC,eAAA,EAAAJ,UAAA,YAA4B,CAA2C;a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;AACrD;AAEA,OAAM,SAAUG,KAAKA,CAACN,MAAoB;EACxC,OAAO,CAAOC,IAAe,EAAEC,OAA4B,KAAiB;IAC1E,OAAOxB,MAAA,CAAMsB,MAAM,EAAEC,IAAI,EAAEC,OAAO,CAAC;EACrC,CAAC;AACH;AAEA;;;AAGA,OAAO,MAAMK,GAAG,gBAAyED,KAAK,CAAC,KAAK,CAAC;AAErG;;;AAGA,OAAO,MAAME,IAAI,gBAAyEF,KAAK,CAAC,MAAM,CAAC;AAEvG;;;AAGA,OAAO,MAAMG,GAAG,gBAAyEH,KAAK,CAAC,KAAK,CAAC;AAErG;;;AAGA,OAAO,MAAMI,KAAK,gBAAyEJ,KAAK,CAAC,OAAO,CAAC;AAEzG;;;AAGA,OAAO,MAAMK,GAAG,gBAAyEL,KAAK,CAAC,QAAQ,CAAC;AAExG;;;AAGA,OAAO,MAAMM,IAAI,gBAAyEN,KAAK,CAAC,MAAM,CAAC;AAEvG;;;AAGA,OAAO,MAAMO,OAAO,gBAAyEP,KAAK,CAAC,SAAS,CAAC;AAE7G;;;AAGA,OAAO,MAAMQ,GAAG,gBAAyER,KAAK,CAAC,GAAG,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
var _a, _b;
|
|
2
2
|
import * as tsplus_module_1 from "@fncts/base/data/Tag/constructors";
|
|
3
3
|
export const RouteTypeId = /*#__PURE__*/Symbol.for("fncts.http.RouteTypeId");
|
|
4
|
+
/**
|
|
5
|
+
* @tsplus type fncts.http.Route
|
|
6
|
+
* @tsplus companion fncts.http.RouteOps
|
|
7
|
+
*/
|
|
4
8
|
export class Route {
|
|
5
9
|
constructor() {
|
|
6
10
|
this[_a] = RouteTypeId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.mjs","names":["RouteTypeId","Symbol","for","Route","constructor","_a","RouteContextTypeId","RouteContext","_b","RouteContextTag","tsplus_module_1","makeTag"],"sources":["../../_src/Route/definition.ts"],"sourcesContent":[null],"mappings":";;AAIA,OAAO,MAAMA,WAAW,gBAAGC,MAAM,CAACC,GAAG,CAAC,wBAAwB,CAAC;AAK/D,OAAM,MAAgBC,KAAK;EAA3BC,YAAA;IACW,KAAAC,EAAA,CAAa,GAAgBL,WAAW;EAMnD;;KANYA,WAAW;AAYvB,OAAO,MAAMM,kBAAkB,gBAAGL,MAAM,CAACC,GAAG,CAAC,+BAA+B,CAAC;AAG7E;;;;AAIA,OAAM,MAAgBK,YAAY;EAAlCH,YAAA;IACW,KAAAI,EAAA,CAAoB,GAAuBF,kBAAkB;EAIxE;;KAJYA,kBAAkB;AAM9B;;;AAGA,OAAO,MAAMG,eAAe,gBAAGC,eAAA,CAAAC,OAAA,EAAmB"}
|
|
1
|
+
{"version":3,"file":"definition.mjs","names":["RouteTypeId","Symbol","for","Route","constructor","_a","RouteContextTypeId","RouteContext","_b","RouteContextTag","tsplus_module_1","makeTag"],"sources":["../../_src/Route/definition.ts"],"sourcesContent":[null],"mappings":";;AAIA,OAAO,MAAMA,WAAW,gBAAGC,MAAM,CAACC,GAAG,CAAC,wBAAwB,CAAC;AAK/D;;;;AAIA,OAAM,MAAgBC,KAAK;EAA3BC,YAAA;IACW,KAAAC,EAAA,CAAa,GAAgBL,WAAW;EAMnD;;KANYA,WAAW;AAYvB,OAAO,MAAMM,kBAAkB,gBAAGL,MAAM,CAACC,GAAG,CAAC,+BAA+B,CAAC;AAG7E;;;;AAIA,OAAM,MAAgBK,YAAY;EAAlCH,YAAA;IACW,KAAAI,EAAA,CAAoB,GAAuBF,kBAAkB;EAIxE;;KAJYA,kBAAkB;AAM9B;;;AAGA,OAAO,MAAMG,eAAe,gBAAGC,eAAA,CAAAC,OAAA,EAAmB"}
|
package/_mjs/Router/api.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import * as tsplus_module_5 from "@fncts/base/data/Maybe/api";
|
|
|
7
7
|
import * as tsplus_module_6 from "@fncts/io/IO/api";
|
|
8
8
|
import * as tsplus_module_7 from "@fncts/io/IO/api/environment";
|
|
9
9
|
export const use = use_1;
|
|
10
|
+
export const from = from_1;
|
|
10
11
|
export const concat = concat_1;
|
|
11
12
|
export const prefixAll = prefixAll_1;
|
|
12
13
|
import { RouteImpl } from "../Route/internal.mjs";
|
|
@@ -69,9 +70,23 @@ function use_1(f, __tsplusTrace) {
|
|
|
69
70
|
/**
|
|
70
71
|
* @tsplus static fncts.http.RouterOps from
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
function from_1(routes) {
|
|
73
74
|
return new RouterInternal(tsplus_module_3.from(routes), tsplus_module_1.empty());
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @tsplus static fncts.http.RouterOps routes
|
|
78
|
+
*/
|
|
79
|
+
export function routes(...routes) {
|
|
80
|
+
return from_1(routes);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @tsplus pipeable fncts.http.Router append
|
|
84
|
+
*/
|
|
85
|
+
export function append(route) {
|
|
86
|
+
return self => {
|
|
87
|
+
return new RouterInternal(tsplus_module_2.append(route)(self.routes), self.mounts);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
75
90
|
/**
|
|
76
91
|
* @tsplus pipeable fncts.http.Router concat
|
|
77
92
|
*/
|
|
@@ -87,7 +102,7 @@ function removeTrailingSlash(path) {
|
|
|
87
102
|
function prefixAll_1(prefix) {
|
|
88
103
|
return self => {
|
|
89
104
|
prefix = removeTrailingSlash(prefix);
|
|
90
|
-
return new RouterInternal(tsplus_module_2.map(route => new RouteImpl(route.method, route.path === "/" ? prefix : prefix + route.path, route.handler, tsplus_module_5.orElse(() => tsplus_module_4.just(prefix, fileName_1 + ":
|
|
105
|
+
return new RouterInternal(tsplus_module_2.map(route => new RouteImpl(route.method, route.path === "/" ? prefix : prefix + route.path, route.handler, tsplus_module_5.orElse(() => tsplus_module_4.just(prefix, fileName_1 + ":150:60"))(tsplus_module_5.map(_ => prefix + _)(route.prefix))))(self.routes), tsplus_module_2.map(({
|
|
91
106
|
prefix: path,
|
|
92
107
|
httpApp
|
|
93
108
|
}) => ({
|
package/_mjs/Router/api.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":["use","use_1","concat","concat_1","prefixAll","prefixAll_1","RouteImpl","RouterInternal","empty","tsplus_module_1","route","method","path","handler","self","tsplus_module_2","append","routes","mounts","get","post","put","patch","del","head","options","f","__tsplusTrace","map","prefix","httpApp","
|
|
1
|
+
{"version":3,"file":"api.mjs","names":["use","use_1","from","from_1","concat","concat_1","prefixAll","prefixAll_1","RouteImpl","RouterInternal","empty","tsplus_module_1","route","method","path","handler","self","tsplus_module_2","append","routes","mounts","get","post","put","patch","del","head","options","f","__tsplusTrace","map","prefix","httpApp","tsplus_module_3","that","removeTrailingSlash","endsWith","slice","tsplus_module_5","orElse","tsplus_module_4","just","fileName_1","_","mount","catchAll","tsplus_module_6","catchAllCause","provideService","service","tag","tsplus_module_7","provideSomeService"],"sources":["../../_src/Router/api.ts"],"sourcesContent":[null],"mappings":";;;;;;;;aAmFgBA,GAAG,GAAAC,KAAA;aAWHC,IAAI,GAAAC,MAAA;aAiCJC,MAAM,GAAAC,QAAA;aAYNC,SAAS,GAAAC,WAAA;AAvIzB,SAASC,SAAS,QAAQ,uBAAsB;AAIhD,SAASC,cAAc,QAAQ,gBAAe;AAE9C;;;AAGA,OAAO,MAAMC,KAAK,gBAAyB,IAAID,cAAc,eAACE,eAAA,CAAAD,KAAA,EAAY,eAAEC,eAAA,CAAAD,KAAA,EAAY,CAAC;AAEzF,OAAM,SAAUE,KAAKA,CAACC,MAAoB;EACxC,OAAO,CAASC,IAAe,EAAEC,OAA8B,KACtDC,IAAkB,IACvB,IAAIP,cAAc,CAAWQ,eAAA,CAAAC,MAAA,CAAmB,IAAIV,SAAS,CAACK,MAAM,EAAEC,IAAI,EAAEC,OAAO,CAAC,EAAvDC,IAAI,CAACG,MAAM,CAA6C,EAAEH,IAAI,CAACI,MAAM,CAAC;AACzG;AAEA;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teAddressOverride);
|
|
29
29
|
}
|
|
30
30
|
get headers() {
|
|
31
|
+
// eslint-disable-next-line @0x706b/align-assignments/align-assignments
|
|
31
32
|
this.headersOverride ?? (this.headersOverride = tsplus_module_2.fromHeaders(this.source.headers));
|
|
32
33
|
return this.headersOverride;
|
|
33
34
|
}
|
|
@@ -35,34 +36,34 @@ export class ServerRequestImpl extends ServerRequest {
|
|
|
35
36
|
if (this.textIO) {
|
|
36
37
|
return this.textIO;
|
|
37
38
|
}
|
|
38
|
-
this.textIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.text(), error => new RequestError(this, "Decode", error), fileName_1 + ":
|
|
39
|
+
this.textIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.text(), error => new RequestError(this, "Decode", error), fileName_1 + ":43:38"), fileName_1 + ":46:6")));
|
|
39
40
|
return this.textIO;
|
|
40
41
|
}
|
|
41
42
|
get json() {
|
|
42
|
-
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => JSON.parse(text), error => new RequestError(this, "Decode", error), fileName_1 + ":
|
|
43
|
+
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => JSON.parse(text), error => new RequestError(this, "Decode", error), fileName_1 + ":53:18"), fileName_1 + ":52:29")(this.text);
|
|
43
44
|
}
|
|
44
45
|
get urlParamsBody() {
|
|
45
|
-
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => tsplus_module_7.make(new URLSearchParams(text)), error => new RequestError(this, "Decode", error), fileName_1 + ":
|
|
46
|
+
return tsplus_module_3.flatMap(text => tsplus_module_3.tryCatch(() => tsplus_module_7.make(new URLSearchParams(text)), error => new RequestError(this, "Decode", error), fileName_1 + ":62:18"), fileName_1 + ":61:29")(this.text);
|
|
46
47
|
}
|
|
47
48
|
get arrayBuffer() {
|
|
48
49
|
if (this.arrayBufferIO) {
|
|
49
50
|
return this.arrayBufferIO;
|
|
50
51
|
}
|
|
51
|
-
this.arrayBufferIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.arrayBuffer(), error => new RequestError(this, "Decode", error), fileName_1 + ":
|
|
52
|
+
this.arrayBufferIO = tsplus_module_6.getOrThrow(tsplus_module_5.unsafeRun(tsplus_module_4.memoize(tsplus_module_3.fromPromiseCatch(() => this.source.arrayBuffer(), error => new RequestError(this, "Decode", error), fileName_1 + ":75:45"), fileName_1 + ":78:6")));
|
|
52
53
|
return this.arrayBufferIO;
|
|
53
54
|
}
|
|
54
55
|
get stream() {
|
|
55
56
|
if (this.source.body) {
|
|
56
57
|
return tsplus_module_8.fromReadableStream(() => this.source.body, error => new RequestError(this, "Decode", error));
|
|
57
58
|
} else {
|
|
58
|
-
return tsplus_module_8.failNow(new RequestError(this, "Decode", "cannot create stream from empty body"), fileName_1 + ":
|
|
59
|
+
return tsplus_module_8.failNow(new RequestError(this, "Decode", "cannot create stream from empty body"), fileName_1 + ":87:28");
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
modify(options) {
|
|
62
63
|
return new ServerRequestImpl(this.source, options.url ?? this.url, options.headers ?? this.headers, options.remoteAddress ?? this.remoteAddressOverride);
|
|
63
64
|
}
|
|
64
65
|
get upgrade() {
|
|
65
|
-
return tsplus_module_3.failNow(new RequestError(this, "Decode", "Not an upgradeable ServerRequest"), fileName_1 + ":
|
|
66
|
+
return tsplus_module_3.failNow(new RequestError(this, "Decode", "Not an upgradeable ServerRequest"), fileName_1 + ":105:22");
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
//# sourceMappingURL=internal.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.mjs","names":["RequestError","UrlParams","ServerRequest","ServerRequestImpl","constructor","source","url","headersOverride","remoteAddressOverride","method","toUpperCase","originalUrl","remoteAddress","tsplus_module_1","fromNullable","headers","tsplus_module_2","fromHeaders","text","textIO","tsplus_module_6","getOrThrow","tsplus_module_5","unsafeRun","tsplus_module_4","memoize","tsplus_module_3","fromPromiseCatch","error","fileName_1","json","flatMap","tryCatch","JSON","parse","urlParamsBody","tsplus_module_7","make","URLSearchParams","arrayBuffer","arrayBufferIO","stream","body","tsplus_module_8","fromReadableStream","failNow","modify","options","upgrade"],"sources":["../../_src/ServerRequest/internal.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;AAIA,SAASA,YAAY,QAAQ,qBAAoB;AACjD,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,aAAa,QAAQ,kBAAiB;AAE/C,OAAM,MAAOC,iBAAkB,SAAQD,aAAa;EAClDE,YACWC,MAAe,EACfC,GAAW,EACbC,eAAyB,EACxBC,qBAA8B;IAEtC,KAAK,EAAE;IALE,KAAAH,MAAM,GAANA,MAAM;IACN,KAAAC,GAAG,GAAHA,GAAG;IACL,KAAAC,eAAe,GAAfA,eAAe;IACd,KAAAC,qBAAqB,GAArBA,qBAAqB;EAG/B;EAEA,IAAIC,MAAMA,CAAA;IACR,OAAO,IAAI,CAACJ,MAAM,CAACI,MAAM,CAACC,WAAW,EAAY;EACnD;EAEA,IAAIC,WAAWA,CAAA;IACb,OAAO,IAAI,CAACN,MAAM,CAACC,GAAG;EACxB;EAEA,IAAIM,aAAaA,CAAA;IACf,OAAOC,eAAA,CAAAC,YAAA,CAAmB,IAAI,CAACN,qBAAqB,CAAC;EACvD;EAEA,IAAIO,OAAOA,CAAA;IACT,IAAI,CAACR,eAAe,KAApB,IAAI,CAACA,eAAe,GAAKS,eAAA,CAAAC,WAAA,CAAoB,IAAI,CAACZ,MAAM,CAACU,OAAO,CAAC;IACjE,OAAO,IAAI,CAACR,eAAe;EAC7B;EAGA,IAAIW,IAAIA,CAAA;IACN,IAAI,IAAI,CAACC,MAAM,EAAE;MACf,OAAO,IAAI,CAACA,MAAM;IACpB;IAEA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KAAK,IAAK,IAAI5B,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE4B,KAAK,CAAC,EAAAC,UAAA,YACnD,EAAAA,UAAA,aAA6B;IAE9B,OAAO,IAAI,CAACW,aAAa;EAC3B;EAEA,IAAIC,MAAMA,CAAA;IACR,IAAI,IAAI,CAACpC,MAAM,CAACqC,IAAI,EAAE;MACpB,OAAOC,eAAA,CAAAC,kBAAA,OAA0B,IAAI,CAACvC,MAAM,CAACqC,IAAI,EAAGd,KAAK,IAAK,IAAI5B,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE4B,KAAK,CAAC,CAAC;IACxG,CAAC,MAAM;MACL,OAAOe,eAAA,CAAAE,OAAA,CAAe,IAAI7C,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,sCAAsC,CAAC,EAAA6B,UAAA,YAAC;IACjG;EACF;EAEAiB,MAAMA,CAACC,OAIN;IACC,OAAO,IAAI5C,iBAAiB,CAC1B,IAAI,CAACE,MAAM,EACX0C,OAAO,CAACzC,GAAG,IAAI,IAAI,CAACA,GAAG,EACvByC,OAAO,CAAChC,OAAO,IAAI,IAAI,CAACA,OAAO,EAC/BgC,OAAO,CAACnC,aAAa,IAAI,IAAI,CAACJ,qBAAqB,CACpD;EACH;EAEA,IAAIwC,OAAOA,CAAA;IACT,OAAOtB,eAAA,CAAAmB,OAAA,CAAW,IAAI7C,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,kCAAkC,CAAC,EAAA6B,UAAA,aAAC;EACzF"}
|
|
1
|
+
{"version":3,"file":"internal.mjs","names":["RequestError","UrlParams","ServerRequest","ServerRequestImpl","constructor","source","url","headersOverride","remoteAddressOverride","method","toUpperCase","originalUrl","remoteAddress","tsplus_module_1","fromNullable","headers","tsplus_module_2","fromHeaders","text","textIO","tsplus_module_6","getOrThrow","tsplus_module_5","unsafeRun","tsplus_module_4","memoize","tsplus_module_3","fromPromiseCatch","error","fileName_1","json","flatMap","tryCatch","JSON","parse","urlParamsBody","tsplus_module_7","make","URLSearchParams","arrayBuffer","arrayBufferIO","stream","body","tsplus_module_8","fromReadableStream","failNow","modify","options","upgrade"],"sources":["../../_src/ServerRequest/internal.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;AAIA,SAASA,YAAY,QAAQ,qBAAoB;AACjD,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,aAAa,QAAQ,kBAAiB;AAE/C,OAAM,MAAOC,iBAAkB,SAAQD,aAAa;EAClDE,YACWC,MAAe,EACfC,GAAW,EACbC,eAAyB,EACxBC,qBAA8B;IAEtC,KAAK,EAAE;IALE,KAAAH,MAAM,GAANA,MAAM;IACN,KAAAC,GAAG,GAAHA,GAAG;IACL,KAAAC,eAAe,GAAfA,eAAe;IACd,KAAAC,qBAAqB,GAArBA,qBAAqB;EAG/B;EAEA,IAAIC,MAAMA,CAAA;IACR,OAAO,IAAI,CAACJ,MAAM,CAACI,MAAM,CAACC,WAAW,EAAY;EACnD;EAEA,IAAIC,WAAWA,CAAA;IACb,OAAO,IAAI,CAACN,MAAM,CAACC,GAAG;EACxB;EAEA,IAAIM,aAAaA,CAAA;IACf,OAAOC,eAAA,CAAAC,YAAA,CAAmB,IAAI,CAACN,qBAAqB,CAAC;EACvD;EAEA,IAAIO,OAAOA,CAAA;IACT;IACA,IAAI,CAACR,eAAe,KAApB,IAAI,CAACA,eAAe,GAAKS,eAAA,CAAAC,WAAA,CAAoB,IAAI,CAACZ,MAAM,CAACU,OAAO,CAAC;IACjE,OAAO,IAAI,CAACR,eAAe;EAC7B;EAGA,IAAIW,IAAIA,CAAA;IACN,IAAI,IAAI,CAACC,MAAM,EAAE;MACf,OAAO,IAAI,CAACA,MAAM;IACpB;IAEA,IAAI,CAACA,MAAM,GAAAC,eAAA,CAAAC,UAAA,CAAAC,eAAA,CAAAC,SAAA,CAAAC,eAAA,CAAAC,OAAA,CAAGC,eAAA,CAAAC,gBAAA,OACZ,IAAI,CAACtB,MAAM,CAACa,IAAI,EAAE,EACjBU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;IACR,IAAI,IAAI,CAACpC,MAAM,CAACqC,IAAI,EAAE;MACpB,OAAOC,eAAA,CAAAC,kBAAA,OAA0B,IAAI,CAACvC,MAAM,CAACqC,IAAI,EAAGd,KAAK,IAAK,IAAI5B,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE4B,KAAK,CAAC,CAAC;IACxG,CAAC,MAAM;MACL,OAAOe,eAAA,CAAAE,OAAA,CAAe,IAAI7C,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,sCAAsC,CAAC,EAAA6B,UAAA,YAAC;IACjG;EACF;EAEAiB,MAAMA,CAACC,OAIN;IACC,OAAO,IAAI5C,iBAAiB,CAC1B,IAAI,CAACE,MAAM,EACX0C,OAAO,CAACzC,GAAG,IAAI,IAAI,CAACA,GAAG,EACvByC,OAAO,CAAChC,OAAO,IAAI,IAAI,CAACA,OAAO,EAC/BgC,OAAO,CAACnC,aAAa,IAAI,IAAI,CAACJ,qBAAqB,CACpD;EACH;EAEA,IAAIwC,OAAOA,CAAA;IACT,OAAOtB,eAAA,CAAAmB,OAAA,CAAW,IAAI7C,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,kCAAkC,CAAC,EAAA6B,UAAA,aAAC;EACzF"}
|
package/_src/ResponseError.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServerRequest } from "@fncts/http/ServerRequest";
|
|
2
|
-
import { ServerResponse } from "@fncts/http/ServerResponse";
|
|
1
|
+
import type { ServerRequest } from "@fncts/http/ServerRequest";
|
|
2
|
+
import type { ServerResponse } from "@fncts/http/ServerResponse";
|
|
3
3
|
|
|
4
4
|
export const ResponseErrorTypeId = Symbol.for("fncts.http.ResponseError");
|
|
5
5
|
export type ResponseErrorTypeId = typeof ResponseErrorTypeId;
|
package/_src/Route/api.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Method } from "../Method.js";
|
|
2
|
-
import type { PathInput
|
|
2
|
+
import type { PathInput } from "./definition.js";
|
|
3
3
|
|
|
4
|
-
import { RouteContext } from "./definition.js";
|
|
4
|
+
import { Route, RouteContext } from "./definition.js";
|
|
5
5
|
import { RouteImpl } from "./internal.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -44,10 +44,56 @@ export function schemaSearchParams<A>(schema: Schema<A>): IO<RouteContext, Parse
|
|
|
44
44
|
* @tsplus static fncts.http.RouteOps __call
|
|
45
45
|
*/
|
|
46
46
|
export function make<R, E>(
|
|
47
|
-
method: Method,
|
|
47
|
+
method: Method | "*",
|
|
48
48
|
path: PathInput,
|
|
49
49
|
handler: Route.Handler<R, E>,
|
|
50
50
|
prefix: Maybe<string> = Nothing(),
|
|
51
51
|
): Route<R, E> {
|
|
52
52
|
return new RouteImpl(method, path, handler, prefix);
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
export function route(method: Method | "*") {
|
|
56
|
+
return <R, E>(path: PathInput, handler: Route.Handler<R, E>): Route<R, E> => {
|
|
57
|
+
return Route(method, path, handler);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @tsplus static fncts.http.RouteOps get
|
|
63
|
+
*/
|
|
64
|
+
export const get: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("GET");
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @tsplus static fncts.http.RouteOps post
|
|
68
|
+
*/
|
|
69
|
+
export const post: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("POST");
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @tsplus static fncts.http.RouteOps put
|
|
73
|
+
*/
|
|
74
|
+
export const put: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("PUT");
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @tsplus static fncts.http.RouteOps patch
|
|
78
|
+
*/
|
|
79
|
+
export const patch: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("PATCH");
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @tsplus static fncts.http.RouteOps del
|
|
83
|
+
*/
|
|
84
|
+
export const del: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("DELETE");
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @tsplus static fncts.http.RouteOps head
|
|
88
|
+
*/
|
|
89
|
+
export const head: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("HEAD");
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @tsplus static fncts.http.RouteOps options
|
|
93
|
+
*/
|
|
94
|
+
export const options: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("OPTIONS");
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @tsplus static fncts.http.RouteOps all
|
|
98
|
+
*/
|
|
99
|
+
export const all: <R, E>(path: PathInput, handler: Route.Handler<R, E>) => Route<R, E> = route("*");
|
package/_src/Route/definition.ts
CHANGED
|
@@ -7,6 +7,10 @@ export type RouteTypeId = typeof RouteTypeId;
|
|
|
7
7
|
|
|
8
8
|
export type PathInput = `/${string}` | "*";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @tsplus type fncts.http.Route
|
|
12
|
+
* @tsplus companion fncts.http.RouteOps
|
|
13
|
+
*/
|
|
10
14
|
export abstract class Route<R, E> {
|
|
11
15
|
readonly [RouteTypeId]: RouteTypeId = RouteTypeId;
|
|
12
16
|
|
package/_src/Router/api.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HttpApp } from "../HttpApp.js";
|
|
2
2
|
import type { Method } from "../Method.js";
|
|
3
3
|
import type { PathInput, Route } from "../Route.js";
|
|
4
|
-
import type { Router } from "./definition.js";
|
|
5
4
|
|
|
6
5
|
import { RouteImpl } from "../Route/internal.js";
|
|
6
|
+
import { ServerRequest } from "../ServerRequest.js";
|
|
7
|
+
import { ServerResponse } from "../ServerResponse.js";
|
|
8
|
+
import { Router } from "./definition.js";
|
|
7
9
|
import { RouterInternal } from "./internal.js";
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -92,10 +94,34 @@ export function use<R, E, R1, E1>(f: (self: Route.Handler<R, E>) => HttpApp.Defa
|
|
|
92
94
|
*/
|
|
93
95
|
export function from<R extends Route<any, any>>(
|
|
94
96
|
routes: Iterable<R>,
|
|
95
|
-
): Router<
|
|
97
|
+
): Router<
|
|
98
|
+
R extends Route<infer Env, infer _> ? Router.ExcludeProvided<Env> : never,
|
|
99
|
+
R extends Route<infer _, infer E> ? E : never
|
|
100
|
+
> {
|
|
96
101
|
return new RouterInternal(Conc.from(routes), Conc.empty());
|
|
97
102
|
}
|
|
98
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @tsplus static fncts.http.RouterOps routes
|
|
106
|
+
*/
|
|
107
|
+
export function routes<Rs extends Array<Route<any, any>>>(
|
|
108
|
+
...routes: Rs
|
|
109
|
+
): Router<
|
|
110
|
+
{ [K in keyof Rs]: Rs[K] extends Route<infer Env, infer _> ? Router.ExcludeProvided<Env> : never }[number],
|
|
111
|
+
{ [K in keyof Rs]: Rs[K] extends Route<infer _, infer E> ? E : never }[number]
|
|
112
|
+
> {
|
|
113
|
+
return Router.from(routes);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @tsplus pipeable fncts.http.Router append
|
|
118
|
+
*/
|
|
119
|
+
export function append<R1, E1>(route: Route<R1, E1>) {
|
|
120
|
+
return <R, E>(self: Router<R, E>): Router<R | Router.ExcludeProvided<R1>, E | E1> => {
|
|
121
|
+
return new RouterInternal<any, any>(self.routes.append(route), self.mounts);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
99
125
|
/**
|
|
100
126
|
* @tsplus pipeable fncts.http.Router concat
|
|
101
127
|
*/
|
|
@@ -29,6 +29,7 @@ export class ServerRequestImpl extends ServerRequest {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
get headers() {
|
|
32
|
+
// eslint-disable-next-line @0x706b/align-assignments/align-assignments
|
|
32
33
|
this.headersOverride ??= Headers.fromHeaders(this.source.headers);
|
|
33
34
|
return this.headersOverride;
|
|
34
35
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fncts/http",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@fncts/base": "0.0.
|
|
6
|
-
"@fncts/io": "0.0.
|
|
7
|
-
"@fncts/schema": "0.0.
|
|
8
|
-
"@fncts/typelevel": "0.0.
|
|
5
|
+
"@fncts/base": "0.0.35",
|
|
6
|
+
"@fncts/io": "0.0.43",
|
|
7
|
+
"@fncts/schema": "0.0.15",
|
|
8
|
+
"@fncts/typelevel": "0.0.18",
|
|
9
9
|
"find-my-way": "^8.1.0",
|
|
10
10
|
"find-my-way-ts": "^0.1.1",
|
|
11
11
|
"isows": "^1.0.4",
|