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.
- package/CHANGELOG.md +19 -0
- package/README.md +119 -1
- package/core/configuration.js +30 -25
- package/core/fetch-router.js +36 -23
- package/core/fetch-router.test.js +50 -22
- package/core/http.js +20 -21
- package/core/migrator.test.js +3 -4
- package/core/types.ts +41 -0
- package/core/utilities.js +10 -4
- package/package.json +12 -1
- package/source/node-router.js +8 -1
- package/source/package.json +9 -0
- package/source/postgres.js +18 -1
- package/tsconfig.json +17 -0
- package/types/core/configuration.d.ts +57 -0
- package/types/core/configuration.d.ts.map +1 -0
- package/types/core/configuration.test.d.ts +2 -0
- package/types/core/configuration.test.d.ts.map +1 -0
- package/types/core/fetch-router.d.ts +52 -0
- package/types/core/fetch-router.d.ts.map +1 -0
- package/types/core/fetch-router.test.d.ts +2 -0
- package/types/core/fetch-router.test.d.ts.map +1 -0
- package/types/core/http.d.ts +55 -0
- package/types/core/http.d.ts.map +1 -0
- package/types/core/http.test.d.ts +2 -0
- package/types/core/http.test.d.ts.map +1 -0
- package/types/core/migrator.d.ts +56 -0
- package/types/core/migrator.d.ts.map +1 -0
- package/types/core/migrator.test.d.ts +2 -0
- package/types/core/migrator.test.d.ts.map +1 -0
- package/types/core/mod.d.ts +7 -0
- package/types/core/mod.d.ts.map +1 -0
- package/types/core/postgres.d.ts +43 -0
- package/types/core/postgres.d.ts.map +1 -0
- package/types/core/test-deps.d.ts +2 -0
- package/types/core/test-deps.d.ts.map +1 -0
- package/types/core/types.d.ts +23 -0
- package/types/core/types.d.ts.map +1 -0
- package/types/core/utilities.d.ts +13 -0
- package/types/core/utilities.d.ts.map +1 -0
- package/types/core/utilities.test.d.ts +2 -0
- package/types/core/utilities.test.d.ts.map +1 -0
- package/types/source/configuration.d.ts +24 -0
- package/types/source/configuration.d.ts.map +1 -0
- package/types/source/core.d.ts +2 -0
- package/types/source/core.d.ts.map +1 -0
- package/types/source/express-router.d.ts +28 -0
- package/types/source/express-router.d.ts.map +1 -0
- package/types/source/koa-router.d.ts +33 -0
- package/types/source/koa-router.d.ts.map +1 -0
- package/types/source/mod.d.ts +7 -0
- package/types/source/mod.d.ts.map +1 -0
- package/types/source/node-router.d.ts +42 -0
- package/types/source/node-router.d.ts.map +1 -0
- package/types/source/polyfill.d.ts +2 -0
- package/types/source/polyfill.d.ts.map +1 -0
- package/types/source/postgres.d.ts +32 -0
- 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 @@
|
|
|
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"}
|