gruber 0.2.0 → 0.4.0

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +156 -16
  3. package/core/configuration.d.ts +157 -0
  4. package/core/configuration.js +222 -96
  5. package/core/configuration.test.d.ts +1 -0
  6. package/core/configuration.test.js +242 -53
  7. package/{types/core → core}/fetch-router.d.ts +0 -1
  8. package/core/fetch-router.test.d.ts +1 -0
  9. package/{types/core → core}/http.d.ts +30 -12
  10. package/core/http.js +42 -17
  11. package/core/http.test.d.ts +1 -0
  12. package/core/http.test.js +57 -35
  13. package/{types/core → core}/migrator.d.ts +0 -1
  14. package/core/migrator.test.d.ts +1 -0
  15. package/{types/core → core}/mod.d.ts +1 -1
  16. package/core/mod.js +1 -0
  17. package/{types/core → core}/postgres.d.ts +0 -1
  18. package/core/structures.d.ts +91 -0
  19. package/core/structures.js +260 -0
  20. package/core/structures.test.d.ts +1 -0
  21. package/core/structures.test.js +474 -0
  22. package/core/test-deps.d.ts +1 -0
  23. package/core/test-deps.js +1 -1
  24. package/{types/core → core}/types.d.ts +0 -1
  25. package/{types/core → core}/utilities.d.ts +0 -1
  26. package/core/utilities.test.d.ts +1 -0
  27. package/package.json +4 -5
  28. package/{types/source → source}/configuration.d.ts +4 -9
  29. package/source/configuration.js +0 -2
  30. package/source/core.d.ts +1 -0
  31. package/{types/source → source}/express-router.d.ts +2 -3
  32. package/source/express-router.js +1 -1
  33. package/{types/source → source}/koa-router.d.ts +0 -1
  34. package/{types/source → source}/mod.d.ts +0 -3
  35. package/source/mod.js +2 -2
  36. package/{types/source → source}/node-router.d.ts +8 -8
  37. package/source/node-router.js +1 -1
  38. package/source/package-lock.json +3 -9
  39. package/source/package.json +0 -2
  40. package/source/polyfill.d.ts +1 -0
  41. package/{types/source → source}/postgres.d.ts +0 -1
  42. package/tsconfig.json +0 -2
  43. package/types/core/configuration.d.ts +0 -57
  44. package/types/core/configuration.d.ts.map +0 -1
  45. package/types/core/configuration.test.d.ts +0 -2
  46. package/types/core/configuration.test.d.ts.map +0 -1
  47. package/types/core/fetch-router.d.ts.map +0 -1
  48. package/types/core/fetch-router.test.d.ts +0 -2
  49. package/types/core/fetch-router.test.d.ts.map +0 -1
  50. package/types/core/http.d.ts.map +0 -1
  51. package/types/core/http.test.d.ts +0 -2
  52. package/types/core/http.test.d.ts.map +0 -1
  53. package/types/core/migrator.d.ts.map +0 -1
  54. package/types/core/migrator.test.d.ts +0 -2
  55. package/types/core/migrator.test.d.ts.map +0 -1
  56. package/types/core/mod.d.ts.map +0 -1
  57. package/types/core/postgres.d.ts.map +0 -1
  58. package/types/core/test-deps.d.ts +0 -2
  59. package/types/core/test-deps.d.ts.map +0 -1
  60. package/types/core/types.d.ts.map +0 -1
  61. package/types/core/utilities.d.ts.map +0 -1
  62. package/types/core/utilities.test.d.ts +0 -2
  63. package/types/core/utilities.test.d.ts.map +0 -1
  64. package/types/source/configuration.d.ts.map +0 -1
  65. package/types/source/core.d.ts +0 -2
  66. package/types/source/core.d.ts.map +0 -1
  67. package/types/source/express-router.d.ts.map +0 -1
  68. package/types/source/koa-router.d.ts.map +0 -1
  69. package/types/source/mod.d.ts.map +0 -1
  70. package/types/source/node-router.d.ts.map +0 -1
  71. package/types/source/polyfill.d.ts +0 -2
  72. package/types/source/polyfill.d.ts.map +0 -1
  73. package/types/source/postgres.d.ts.map +0 -1
@@ -0,0 +1,474 @@
1
+ import { StructError, Structure } from "./structures.js";
2
+ import {
3
+ assertEquals,
4
+ assertThrows,
5
+ describe,
6
+ it,
7
+ assertInstanceOf,
8
+ } from "./test-deps.js";
9
+
10
+ describe("StructError", () => {
11
+ describe("constructor", () => {
12
+ it("stores values", () => {
13
+ const err = new StructError("error message", "some.path");
14
+ assertEquals(err.path, "some.path");
15
+ assertEquals(err.message, "error message");
16
+ assertEquals(err.name, "StructError");
17
+ });
18
+ it("stores children", () => {
19
+ const child = new StructError("child message", "path");
20
+ const parent = new StructError("parent message", "path", [child]);
21
+ assertEquals(parent.children, [child]);
22
+ });
23
+ });
24
+
25
+ describe("chain", () => {
26
+ it("returns StructErrors", () => {
27
+ const ctx = { path: ["some", "path"] };
28
+ const result = StructError.chain(
29
+ new StructError("error message", ["another", "path"]),
30
+ ctx,
31
+ );
32
+ assertEquals(
33
+ result,
34
+ new StructError("error message", ["another", "path"]),
35
+ "returns the StructError without modifying the path",
36
+ );
37
+ });
38
+ it("wraps Errors", () => {
39
+ const ctx = { path: ["some", "path"] };
40
+ const result = StructError.chain(new Error("error message"), ctx);
41
+ assertEquals(
42
+ result,
43
+ new StructError("error message", ["some", "path"]),
44
+ "creates a StructError and sets the path from the context",
45
+ );
46
+ });
47
+ it("wraps non-Errors", () => {
48
+ const ctx = { path: ["some", "path"] };
49
+ const result = StructError.chain("unknown", ctx);
50
+ assertEquals(
51
+ result,
52
+ new StructError("Unknown error", ["some", "path"]),
53
+ "creates a generic StructError",
54
+ );
55
+ });
56
+ });
57
+
58
+ describe("getOneLiner", () => {
59
+ it("formats the error", () => {
60
+ const error = new StructError("error message", ["some", "path"]);
61
+ assertEquals(error.getOneLiner(), "some.path — error message");
62
+ });
63
+ });
64
+
65
+ describe("[Symbol.iterator]", () => {
66
+ it("yields children", () => {
67
+ const error = new StructError(
68
+ "error message",
69
+ ["some", "path"],
70
+ [
71
+ new StructError("child a"),
72
+ new StructError("child b"),
73
+ new StructError("child c"),
74
+ ],
75
+ );
76
+ assertEquals(
77
+ Array.from(error, (i) => i.message),
78
+ ["child a", "child b", "child c"],
79
+ "should yield each child",
80
+ );
81
+ });
82
+ it("yields nested children", () => {
83
+ const error = new StructError(
84
+ "parent a",
85
+ ["some"],
86
+ [
87
+ new StructError(
88
+ "parent b",
89
+ ["path"],
90
+ [
91
+ new StructError("child a"),
92
+ new StructError("child b"),
93
+ new StructError("child c"),
94
+ ],
95
+ ),
96
+ ],
97
+ );
98
+ assertEquals(
99
+ Array.from(error, (i) => i.message),
100
+ ["child a", "child b", "child c"],
101
+ "should yield all nested children which have no children of their own",
102
+ );
103
+ });
104
+ });
105
+
106
+ describe("toFriendlyString", () => {
107
+ it("formats a message", () => {
108
+ const error = new StructError(
109
+ "parent message",
110
+ ["some", "path"],
111
+ [
112
+ new StructError("child a", ["some", "path", "a"]),
113
+ new StructError("child b", ["some", "path", "b"]),
114
+ new StructError("child c", ["some", "path", "c"]),
115
+ ],
116
+ );
117
+
118
+ assertEquals(
119
+ error.toFriendlyString(),
120
+ [
121
+ "parent message",
122
+ " some.path.a — child a",
123
+ " some.path.b — child b",
124
+ " some.path.c — child c",
125
+ ].join("\n"),
126
+ );
127
+ });
128
+ });
129
+ });
130
+
131
+ describe("Structure", () => {
132
+ describe("constructor", () => {
133
+ it("stores fields", () => {
134
+ const result = new Structure("schema", "process");
135
+ assertEquals(result.schema, "schema");
136
+ assertEquals(result.process, "process");
137
+ });
138
+ });
139
+
140
+ describe("getSchema", () => {
141
+ it("injects $schema", () => {
142
+ const schema = { type: "string", default: "fallback" };
143
+ const struct = new Structure(schema, () => {});
144
+ assertEquals(
145
+ struct.getSchema(),
146
+ {
147
+ $schema: "https://json-schema.org/draft/2020-12/schema",
148
+ type: "string",
149
+ default: "fallback",
150
+ },
151
+ "should add the $schema variable to make it a valid JSON schema",
152
+ );
153
+ });
154
+ });
155
+
156
+ describe("string", () => {
157
+ it("creates a structure", () => {
158
+ const struct = Structure.string("fallback");
159
+ assertInstanceOf(struct, Structure);
160
+ });
161
+ it("allows strings", () => {
162
+ const struct = Structure.string("fallback");
163
+ assertEquals(
164
+ struct.process("value"),
165
+ "value",
166
+ "should allow string values through",
167
+ );
168
+ });
169
+ it("uses the fallback", () => {
170
+ const struct = Structure.string("fallback");
171
+ assertEquals(
172
+ struct.process(undefined),
173
+ "fallback",
174
+ "should fall back to the default if undefined is passed",
175
+ );
176
+ });
177
+ it("validates strings", () => {
178
+ const struct = Structure.string("fallback");
179
+
180
+ const error = assertThrows(
181
+ () => struct.process(42, { path: ["some", "path"] }),
182
+ StructError,
183
+ );
184
+ assertEquals(error.message, "Expected a string");
185
+ assertEquals(error.path, ["some", "path"], "should capture the context");
186
+ });
187
+ it("validates missing values", () => {
188
+ const struct = Structure.string();
189
+
190
+ const error = assertThrows(
191
+ () => struct.process(undefined, { path: ["some", "path"] }),
192
+ StructError,
193
+ );
194
+ assertEquals(error.message, "Missing value");
195
+ assertEquals(error.path, ["some", "path"], "should capture the context");
196
+ });
197
+ it("generates JSON schema", () => {
198
+ const struct = Structure.string("fallback");
199
+ assertEquals(struct.schema, { type: "string", default: "fallback" });
200
+ });
201
+ });
202
+
203
+ describe("number", () => {
204
+ it("creates a structure", () => {
205
+ const struct = Structure.number(42);
206
+ assertInstanceOf(struct, Structure);
207
+ });
208
+ it("allows numbers", () => {
209
+ const struct = Structure.number(42);
210
+ assertEquals(
211
+ struct.process(33),
212
+ 33,
213
+ "should allow number values through",
214
+ );
215
+ });
216
+ it("uses the fallback", () => {
217
+ const struct = Structure.number(42);
218
+ assertEquals(
219
+ struct.process(undefined),
220
+ 42,
221
+ "should fall back to the default if undefined is passed",
222
+ );
223
+ });
224
+ // TODO: I'm not sure if this should be on Structure or Configuration
225
+ it.skip("parses string integers", () => {
226
+ const struct = Structure.number(42);
227
+ assertEquals(
228
+ struct.process("33"),
229
+ 33,
230
+ "should parse the integer out of the string",
231
+ );
232
+ });
233
+ it.skip("throws for non-numbers", () => {
234
+ const struct = Structure.number(42);
235
+
236
+ const error = assertThrows(
237
+ () => struct.process("a string", { path: ["some", "path"] }),
238
+ StructError,
239
+ );
240
+
241
+ assertEquals(error.message, "Expected a number");
242
+ assertEquals(error.path, ["some", "path"], "should capture the context");
243
+ });
244
+ it("validates missing values", () => {
245
+ const struct = Structure.number();
246
+
247
+ const error = assertThrows(
248
+ () => struct.process(undefined, { path: ["some", "path"] }),
249
+ StructError,
250
+ );
251
+ assertEquals(error.message, "Missing value");
252
+ assertEquals(error.path, ["some", "path"], "should capture the context");
253
+ });
254
+ it("generates JSON schema", () => {
255
+ const struct = Structure.number(42);
256
+ assertEquals(struct.schema, { type: "number", default: 42 });
257
+ });
258
+ });
259
+
260
+ describe("boolean", () => {
261
+ it("creates a structure", () => {
262
+ const struct = Structure.boolean(false);
263
+ assertInstanceOf(struct, Structure);
264
+ });
265
+ it("allows booleans", () => {
266
+ const struct = Structure.boolean(false);
267
+ assertEquals(
268
+ struct.process(true),
269
+ true,
270
+ "should allow boolean values through",
271
+ );
272
+ });
273
+ it("uses the fallback", () => {
274
+ const struct = Structure.boolean(false);
275
+ assertEquals(
276
+ struct.process(undefined),
277
+ false,
278
+ "should fall back to the default if undefined is passed",
279
+ );
280
+ });
281
+ it("throws for non-booleans", () => {
282
+ const struct = Structure.boolean(false);
283
+
284
+ const error = assertThrows(
285
+ () => struct.process("a string", { path: ["some", "path"] }),
286
+ StructError,
287
+ );
288
+ assertEquals(
289
+ error,
290
+ new StructError("Expected a boolean", ["some", "path"]),
291
+ "should throw a StructError and capture the context",
292
+ );
293
+ });
294
+ it("generates JSON schema", () => {
295
+ const struct = Structure.boolean(false);
296
+ assertEquals(struct.schema, { type: "boolean", default: false });
297
+ });
298
+ });
299
+
300
+ describe("url", () => {
301
+ it("creates a structure", () => {
302
+ const struct = Structure.url("https://fallback.example.com");
303
+ assertInstanceOf(struct, Structure);
304
+ });
305
+ it("fail for invalid fallbacks", () => {
306
+ assertThrows(() => Structure.url("not a URL"));
307
+ });
308
+ it("allows strings", () => {
309
+ const struct = Structure.url("https://fallback.example.com");
310
+ assertEquals(
311
+ struct.process("https://example.com"),
312
+ new URL("https://example.com"),
313
+ "should allow strings and convert them to a URL",
314
+ );
315
+ });
316
+ it("allows URLs", () => {
317
+ const struct = Structure.url("https://fallback.example.com");
318
+ assertEquals(
319
+ struct.process(new URL("https://example.com")),
320
+ new URL("https://example.com"),
321
+ "should allow strings and convert them to a URL",
322
+ );
323
+ });
324
+ it("uses the fallback", () => {
325
+ const struct = Structure.url("https://fallback.example.com");
326
+ assertEquals(
327
+ struct.process(undefined),
328
+ new URL("https://fallback.example.com"),
329
+ "should fall back to the default if undefined is passed",
330
+ );
331
+ });
332
+ it("validates non-strings", () => {
333
+ const struct = Structure.url("https://fallback.example.com");
334
+
335
+ const error = assertThrows(
336
+ () => struct.process(42, { path: ["some", "path"] }),
337
+ StructError,
338
+ );
339
+
340
+ assertEquals(error.message, "Not a string or URL");
341
+ assertEquals(error.path, ["some", "path"], "should capture the context");
342
+ });
343
+ it("validates missing values", () => {
344
+ const struct = Structure.url();
345
+
346
+ const error = assertThrows(
347
+ () => struct.process(undefined, { path: ["some", "path"] }),
348
+ StructError,
349
+ );
350
+ assertEquals(error.message, "Missing value");
351
+ assertEquals(error.path, ["some", "path"], "should capture the context");
352
+ });
353
+ it("generates JSON schema", () => {
354
+ const struct = Structure.url("https://fallback.example.com");
355
+ assertEquals(struct.schema, {
356
+ type: "string",
357
+ format: "uri",
358
+ default: "https://fallback.example.com",
359
+ });
360
+ });
361
+ it("stringifies URLs for JSON schema", () => {
362
+ const struct = Structure.url(new URL("https://fallback.example.com"));
363
+ assertEquals(struct.schema, {
364
+ type: "string",
365
+ format: "uri",
366
+ default: "https://fallback.example.com/",
367
+ });
368
+ });
369
+ });
370
+
371
+ describe("object", () => {
372
+ it("creates a structure", () => {
373
+ const struct = Structure.object({
374
+ key: Structure.string("fallback"),
375
+ });
376
+ assertInstanceOf(struct, Structure);
377
+ });
378
+ it("generates JSON schema", () => {
379
+ const struct = Structure.object({
380
+ key: Structure.string("fallback"),
381
+ });
382
+ assertEquals(struct.schema, {
383
+ type: "object",
384
+ properties: {
385
+ key: {
386
+ type: "string",
387
+ default: "fallback",
388
+ },
389
+ },
390
+ default: {},
391
+ additionalProperties: false,
392
+ });
393
+ });
394
+ it("throws for non-objects", () => {
395
+ const struct = Structure.object({
396
+ key: Structure.string("fallback"),
397
+ });
398
+ const error = assertThrows(
399
+ () => struct.process("not an object", { path: ["some", "path"] }),
400
+ StructError,
401
+ );
402
+
403
+ assertEquals(error.message, "Expected an object");
404
+ assertEquals(error.path, ["some", "path"], "should capture the context");
405
+ });
406
+ it("allows objects", () => {
407
+ const struct = Structure.object({
408
+ key: Structure.string("fallback"),
409
+ });
410
+ const result = struct.process({ key: "value" });
411
+ assertEquals(result, { key: "value" });
412
+ });
413
+ it("validates nested values", () => {
414
+ const struct = Structure.object({
415
+ key: Structure.string("fallback"),
416
+ });
417
+ const error = assertThrows(
418
+ () => struct.process({ key: 42 }),
419
+ StructError,
420
+ );
421
+
422
+ assertEquals(error.message, "Object does not match schema");
423
+ assertEquals(error.path, []);
424
+ assertEquals(error.children.length, 1, "should have one nested error");
425
+ assertEquals(error.children[0].message, "Expected a string");
426
+ assertEquals(error.children[0].path, ["key"], "should capture context");
427
+ });
428
+ });
429
+
430
+ describe("array", () => {
431
+ it("creates a structure", () => {
432
+ const struct = Structure.array(Structure.string());
433
+ assertInstanceOf(struct, Structure);
434
+ });
435
+ it("generates JSON schema", () => {
436
+ const struct = Structure.array(Structure.string());
437
+ assertEquals(struct.schema, {
438
+ type: "array",
439
+ items: {
440
+ type: "string",
441
+ },
442
+ default: [],
443
+ });
444
+ });
445
+ it("throws for non-arrays", () => {
446
+ const struct = Structure.array(Structure.string());
447
+ const error = assertThrows(
448
+ () => struct.process("not an object", { path: ["some", "path"] }),
449
+ StructError,
450
+ );
451
+
452
+ assertEquals(error.message, "Expected an array");
453
+ assertEquals(error.path, ["some", "path"], "should capture the context");
454
+ });
455
+ it("allows arrays", () => {
456
+ const struct = Structure.array(Structure.string());
457
+ const result = struct.process(["a", "b", "c"]);
458
+ assertEquals(result, ["a", "b", "c"]);
459
+ });
460
+ it("validates array items", () => {
461
+ const struct = Structure.array(Structure.string());
462
+ const error = assertThrows(
463
+ () => struct.process(["a", 2, "c"]),
464
+ StructError,
465
+ );
466
+
467
+ assertEquals(error.message, "Array item does not match schema");
468
+ assertEquals(error.path, []);
469
+ assertEquals(error.children.length, 1, "should have one nested error");
470
+ assertEquals(error.children[0].message, "Expected a string");
471
+ assertEquals(error.children[0].path, ["1"], "should capture context");
472
+ });
473
+ });
474
+ });
@@ -0,0 +1 @@
1
+ export {};
package/core/test-deps.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from "https://deno.land/std@0.211.0/assert/mod.ts";
2
- export * as superstruct from "npm:superstruct@^1.0.3";
2
+ export * from "https://deno.land/std@0.211.0/testing/bdd.ts";
@@ -20,4 +20,3 @@ export interface RouteDefinition<T> {
20
20
  pattern: URLPattern;
21
21
  handler: RouteHandler<T>;
22
22
  }
23
- //# sourceMappingURL=types.d.ts.map
@@ -10,4 +10,3 @@ export function formatMarkdownTable<T>(fields: T, columns: (keyof T)[], fallback
10
10
  * @returns {T}
11
11
  */
12
12
  export function loader<T extends () => any>(handler: T): T;
13
- //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "gruber",
3
3
  "type": "module",
4
- "license": "MIT",
5
4
  "repository": "robb-j/gruber",
6
5
  "author": {
7
6
  "name": "Rob Anderson",
@@ -11,7 +10,6 @@
11
10
  "node": ">=20"
12
11
  },
13
12
  "dependencies": {
14
- "superstruct": "^1.0.3",
15
13
  "urlpattern-polyfill": "^9.0.0"
16
14
  },
17
15
  "devDependencies": {
@@ -21,13 +19,14 @@
21
19
  },
22
20
  "exports": {
23
21
  ".": {
24
- "types": "./types/mod.d.ts",
25
22
  "import": "./source/mod.js"
26
23
  },
24
+ "./core/*.js": {
25
+ "import": "./core/*.js"
26
+ },
27
27
  "./*.js": {
28
- "types": "./types/*.d.ts",
29
28
  "import": "./source/*.js"
30
29
  }
31
30
  },
32
- "version": "0.2.0"
31
+ "version": "0.4.0"
33
32
  }
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  @typedef {object} NodeConfigurationOptions
3
- @property {import("superstruct")} superstruct
4
3
  */
5
4
  /** @param {NodeConfigurationOptions} options */
6
5
  export function getNodeConfigOptions(options: NodeConfigurationOptions): {
7
- superstruct: typeof import("superstruct");
8
- readTextFile(url: any): Promise<any>;
9
- getEnvironmentVariable(key: any): any;
10
- getCommandArgument(key: any): any;
6
+ readTextFile(url: any): Promise<Buffer>;
7
+ getEnvironmentVariable(key: any): string;
8
+ getCommandArgument(key: any): string | boolean;
11
9
  stringify(config: any): string;
12
10
  parse(data: any): any;
13
11
  };
@@ -17,8 +15,5 @@ export function getNodeConfigOptions(options: NodeConfigurationOptions): {
17
15
  */
18
16
  export function getNodeConfiguration(options: NodeConfigurationOptions): Configuration;
19
17
  export { Configuration };
20
- export type NodeConfigurationOptions = {
21
- superstruct: typeof import("superstruct");
22
- };
18
+ export type NodeConfigurationOptions = object;
23
19
  import { Configuration } from "../core/configuration.js";
24
- //# sourceMappingURL=configuration.d.ts.map
@@ -8,7 +8,6 @@ export { Configuration };
8
8
 
9
9
  /**
10
10
  @typedef {object} NodeConfigurationOptions
11
- @property {import("superstruct")} superstruct
12
11
  */
13
12
 
14
13
  /** @param {NodeConfigurationOptions} options */
@@ -18,7 +17,6 @@ export function getNodeConfigOptions(options) {
18
17
  strict: false,
19
18
  });
20
19
  return {
21
- superstruct: options.superstruct,
22
20
  async readTextFile(url) {
23
21
  try {
24
22
  return await fs.promises.readFile(url);
@@ -0,0 +1 @@
1
+ export * from "../core/mod.js";
@@ -11,8 +11,8 @@
11
11
  ```
12
12
  */
13
13
  export class ExpressRouter {
14
- /** @param {NodeRouterOptions} options */
15
- constructor(options?: NodeRouterOptions);
14
+ /** @param {import("./node-router.js").NodeRouterOptions} options */
15
+ constructor(options?: import("./node-router.js").NodeRouterOptions);
16
16
  router: FetchRouter;
17
17
  /** @returns {import("express").RequestHandler} */
18
18
  middleware(): any;
@@ -25,4 +25,3 @@ export class ExpressRouter {
25
25
  respond(res: any, response: Response): void;
26
26
  }
27
27
  import { FetchRouter } from "../core/fetch-router.js";
28
- //# sourceMappingURL=express-router.d.ts.map
@@ -16,7 +16,7 @@ import { getFetchRequest } from "./node-router.js";
16
16
  ```
17
17
  */
18
18
  export class ExpressRouter {
19
- /** @param {NodeRouterOptions} options */
19
+ /** @param {import("./node-router.js").NodeRouterOptions} options */
20
20
  constructor(options = {}) {
21
21
  this.router = new FetchRouter(options.routes ?? []);
22
22
  }
@@ -30,4 +30,3 @@ export class KoaRouter {
30
30
  export type Context = any;
31
31
  export type NodeRouterOptions = import("./node-router.js").NodeRouterOptions;
32
32
  import { FetchRouter } from "../core/fetch-router.js";
33
- //# sourceMappingURL=koa-router.d.ts.map
@@ -1,7 +1,4 @@
1
1
  export * from "./configuration.js";
2
2
  export * from "./core.js";
3
- export * from "./express-router.js";
4
- export * from "./koa-router.js";
5
3
  export * from "./node-router.js";
6
4
  export * from "./postgres.js";
7
- //# sourceMappingURL=mod.d.ts.map
package/source/mod.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from "./configuration.js";
2
2
  export * from "./core.js";
3
- export * from "./express-router.js";
4
- export * from "./koa-router.js";
3
+ // export * from "./express-router.js";
4
+ // export * from "./koa-router.js";
5
5
  export * from "./node-router.js";
6
6
  export * from "./postgres.js";
@@ -1,10 +1,11 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  /** @param {import("node:http").IncomingMessage} req */
2
- export function getFetchRequest(req: any): Request;
3
+ export function getFetchRequest(req: import("node:http").IncomingMessage): Request;
3
4
  /** @param {import("node:http").IncomingHttpHeaders} input */
4
- export function getFetchHeaders(input: any): Headers;
5
+ export function getFetchHeaders(input: import("node:http").IncomingHttpHeaders): Headers;
5
6
  /** @param {import("node:http").IncomingMessage} req */
6
- export function getIncomingMessageBody(req: any): any;
7
- /** @typedef {import("../../core/mod.js").RouteDefinition} RouteDefinition */
7
+ export function getIncomingMessageBody(req: import("node:http").IncomingMessage): import("stream/web").ReadableStream<any>;
8
+ /** @typedef {import("../core/mod.js").RouteDefinition} RouteDefinition */
8
9
  /**
9
10
  @typedef {object} NodeRouterOptions
10
11
  @property {RouteDefinition []} routes
@@ -32,11 +33,10 @@ export class NodeRouter {
32
33
  @param {import("node:http").ServerResponse} res
33
34
  @param {Response} response
34
35
  */
35
- respond(res: any, response: Response): void;
36
+ respond(res: import("node:http").ServerResponse, response: Response): void;
36
37
  }
37
- export type RouteDefinition = any;
38
+ export type RouteDefinition = import("../core/mod.js").RouteDefinition;
38
39
  export type NodeRouterOptions = {
39
- routes: RouteDefinition[];
40
+ routes: import("../core/types.js").RouteDefinition<any>[];
40
41
  };
41
42
  import { FetchRouter } from "../core/fetch-router.js";
42
- //# sourceMappingURL=node-router.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { Readable } from "node:stream";
2
2
  import { FetchRouter } from "../core/fetch-router.js";
3
3
 
4
- /** @typedef {import("../../core/mod.js").RouteDefinition} RouteDefinition */
4
+ /** @typedef {import("../core/mod.js").RouteDefinition} RouteDefinition */
5
5
 
6
6
  /**
7
7
  @typedef {object} NodeRouterOptions