gruber 0.1.0 → 0.2.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 (58) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +119 -1
  3. package/core/configuration.js +30 -25
  4. package/core/fetch-router.js +36 -23
  5. package/core/fetch-router.test.js +50 -22
  6. package/core/http.js +20 -21
  7. package/core/migrator.test.js +3 -4
  8. package/core/types.ts +41 -0
  9. package/core/utilities.js +10 -4
  10. package/package.json +12 -1
  11. package/source/node-router.js +8 -1
  12. package/source/package.json +9 -0
  13. package/source/postgres.js +18 -1
  14. package/tsconfig.json +17 -0
  15. package/types/core/configuration.d.ts +57 -0
  16. package/types/core/configuration.d.ts.map +1 -0
  17. package/types/core/configuration.test.d.ts +2 -0
  18. package/types/core/configuration.test.d.ts.map +1 -0
  19. package/types/core/fetch-router.d.ts +52 -0
  20. package/types/core/fetch-router.d.ts.map +1 -0
  21. package/types/core/fetch-router.test.d.ts +2 -0
  22. package/types/core/fetch-router.test.d.ts.map +1 -0
  23. package/types/core/http.d.ts +55 -0
  24. package/types/core/http.d.ts.map +1 -0
  25. package/types/core/http.test.d.ts +2 -0
  26. package/types/core/http.test.d.ts.map +1 -0
  27. package/types/core/migrator.d.ts +56 -0
  28. package/types/core/migrator.d.ts.map +1 -0
  29. package/types/core/migrator.test.d.ts +2 -0
  30. package/types/core/migrator.test.d.ts.map +1 -0
  31. package/types/core/mod.d.ts +7 -0
  32. package/types/core/mod.d.ts.map +1 -0
  33. package/types/core/postgres.d.ts +43 -0
  34. package/types/core/postgres.d.ts.map +1 -0
  35. package/types/core/test-deps.d.ts +2 -0
  36. package/types/core/test-deps.d.ts.map +1 -0
  37. package/types/core/types.d.ts +23 -0
  38. package/types/core/types.d.ts.map +1 -0
  39. package/types/core/utilities.d.ts +13 -0
  40. package/types/core/utilities.d.ts.map +1 -0
  41. package/types/core/utilities.test.d.ts +2 -0
  42. package/types/core/utilities.test.d.ts.map +1 -0
  43. package/types/source/configuration.d.ts +24 -0
  44. package/types/source/configuration.d.ts.map +1 -0
  45. package/types/source/core.d.ts +2 -0
  46. package/types/source/core.d.ts.map +1 -0
  47. package/types/source/express-router.d.ts +28 -0
  48. package/types/source/express-router.d.ts.map +1 -0
  49. package/types/source/koa-router.d.ts +33 -0
  50. package/types/source/koa-router.d.ts.map +1 -0
  51. package/types/source/mod.d.ts +7 -0
  52. package/types/source/mod.d.ts.map +1 -0
  53. package/types/source/node-router.d.ts +42 -0
  54. package/types/source/node-router.d.ts.map +1 -0
  55. package/types/source/polyfill.d.ts +2 -0
  56. package/types/source/polyfill.d.ts.map +1 -0
  57. package/types/source/postgres.d.ts +32 -0
  58. package/types/source/postgres.d.ts.map +1 -0
@@ -0,0 +1,42 @@
1
+ /** @param {import("node:http").IncomingMessage} req */
2
+ export function getFetchRequest(req: any): Request;
3
+ /** @param {import("node:http").IncomingHttpHeaders} input */
4
+ export function getFetchHeaders(input: any): Headers;
5
+ /** @param {import("node:http").IncomingMessage} req */
6
+ export function getIncomingMessageBody(req: any): any;
7
+ /** @typedef {import("../../core/mod.js").RouteDefinition} RouteDefinition */
8
+ /**
9
+ @typedef {object} NodeRouterOptions
10
+ @property {RouteDefinition []} routes
11
+ */
12
+ /**
13
+ A HTTP router for Node.js, powered by Koa
14
+
15
+ ```js
16
+ import http from "node:http";
17
+
18
+ const router = new NodeRouter(...)
19
+ const server = http.createServer(router.forHttpServer())
20
+ server.listen(3000)
21
+ ```
22
+ */
23
+ export class NodeRouter {
24
+ /** @param {NodeRouterOptions} options */
25
+ constructor(options?: NodeRouterOptions);
26
+ router: FetchRouter;
27
+ /** @param {Request} request */
28
+ getResponse(request: Request): Promise<Response>;
29
+ forHttpServer(): (req: any, res: any) => Promise<void>;
30
+ onRouteError(error: any, request: any): void;
31
+ /**
32
+ @param {import("node:http").ServerResponse} res
33
+ @param {Response} response
34
+ */
35
+ respond(res: any, response: Response): void;
36
+ }
37
+ export type RouteDefinition = any;
38
+ export type NodeRouterOptions = {
39
+ routes: RouteDefinition[];
40
+ };
41
+ import { FetchRouter } from "../core/fetch-router.js";
42
+ //# sourceMappingURL=node-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-router.d.ts","sourceRoot":"","sources":["../../source/node-router.js"],"names":[],"mappings":"AAiEA,uDAAuD;AACvD,mDAOC;AAED,6DAA6D;AAC7D,qDAOC;AAED,uDAAuD;AACvD,sDAGC;AAtFD,6EAA6E;AAE7E;;;MAGG;AAEH;;;;;;;;;;EAUE;AACF;IACC,yCAAyC;IACzC,sBADY,iBAAiB,EAM5B;IAJA,oBAGE;IAGH,+BAA+B;IAC/B,qBADY,OAAO,qBAGlB;IAED,uDAMC;IAED,6CAEC;IAED;;;MAGE;IACF,4BAFS,QAAQ,QAahB;CACD;;;YAxDW,eAAe,EAAG;;4BANF,yBAAyB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=polyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../../source/polyfill.js"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * TODO: this isn't documented
3
+ * @param {MigrationOptions<Sql>} options
4
+ */
5
+ export function definePostgresMigration(options: MigrationOptions<Sql>): import("../core/migrator.js").MigrationOptions<import("postgres").Sql<any>>;
6
+ /**
7
+ * @typedef {object} NodePostgresMigratorOptions
8
+ * @property {Sql} sql
9
+ * @property {URL} directory
10
+ */
11
+ /**
12
+ * @param {NodePostgresMigratorOptions} options
13
+ * @returns {MigratorOptions}
14
+ */
15
+ export function getNodePostgresMigratorOptions(options: NodePostgresMigratorOptions): any;
16
+ /**
17
+ * This is a syntax sugar for `new Migrator(getNodePostgresMigratorOptions(...))`
18
+ *
19
+ * @param {NodePostgresMigratorOptions} options
20
+ */
21
+ export function getNodePostgresMigrator(options: NodePostgresMigratorOptions): Migrator<any>;
22
+ export type NodePostgresMigratorOptions = {
23
+ sql: Sql;
24
+ directory: URL;
25
+ };
26
+ export type Sql = import("postgres").Sql;
27
+ export type MigratorOptions<T> = import("../core/migrator.js").MigratorOptions<T>;
28
+ export type MigrationOptions<T> = import("../core/migrator.js").MigrationOptions<T>;
29
+ import { Migrator } from "../core/migrator.js";
30
+ import { defineMigration } from "../core/migrator.js";
31
+ export { Migrator, defineMigration };
32
+ //# sourceMappingURL=postgres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../source/postgres.js"],"names":[],"mappings":"AAyBA;;;GAGG;AACH,iDAFW,iBAAiB,GAAG,CAAC,+EAI/B;AAED;;;;GAIG;AAEH;;;GAGG;AACH,wDAHW,2BAA2B,OAuCrC;AAED;;;;GAIG;AACH,iDAFW,2BAA2B,iBAOrC;;SAxDa,GAAG;eACH,GAAG;;kBAzBH,OAAO,UAAU,EAAE,GAAG;iCAIvB,OAAO,qBAAqB,EAAE,eAAe,CAAC,CAAC,CAAC;kCAKhD,OAAO,qBAAqB,EAAE,gBAAgB,CAAC,CAAC,CAAC;yBAjBpB,qBAAqB;gCAArB,qBAAqB"}