@molecule/api-bonds-default-express 1.0.3 → 1.1.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/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-06T05:03:56.372Z
6
+ Generated: 2026-10-06T19:54:54.472Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-bonds-default-express
@@ -79,7 +79,7 @@ const billingRouter = createBillingRouter<AppLimits>({
79
79
  ## Installation
80
80
 
81
81
  ```bash
82
- npm install @molecule/api-bonds-default-express @molecule/api-ai-anthropic @molecule/api-ai-embeddings @molecule/api-ai-embeddings-openai @molecule/api-ai-openai @molecule/api-ai-speech @molecule/api-ai-speech-openai @molecule/api-ai-vector-store @molecule/api-ai-vector-store-pgvector @molecule/api-analytics @molecule/api-audit @molecule/api-audit-database @molecule/api-bond @molecule/api-cache @molecule/api-cache-memory @molecule/api-cache-redis @molecule/api-config @molecule/api-config-env @molecule/api-cron @molecule/api-cron-node-cron @molecule/api-database @molecule/api-database-postgresql @molecule/api-emails @molecule/api-emails-capture @molecule/api-emails-mailgun @molecule/api-encryption @molecule/api-encryption-aes @molecule/api-entitlements @molecule/api-error-tracking @molecule/api-error-tracking-console @molecule/api-error-tracking-sentry @molecule/api-geolocation @molecule/api-geolocation-google @molecule/api-geolocation-mapbox @molecule/api-geolocation-nominatim @molecule/api-http @molecule/api-http-fetch @molecule/api-i18n @molecule/api-image @molecule/api-image-sharp @molecule/api-import-export @molecule/api-import-export-csv @molecule/api-jwt @molecule/api-jwt-jsonwebtoken @molecule/api-logger @molecule/api-media-streaming @molecule/api-media-streaming-hls @molecule/api-middleware-body-parser @molecule/api-middleware-body-parser-express @molecule/api-middleware-cookie-parser @molecule/api-middleware-cookie-parser-express @molecule/api-middleware-cors @molecule/api-middleware-cors-express @molecule/api-middleware-validation @molecule/api-notifications-webhook @molecule/api-password @molecule/api-password-bcrypt @molecule/api-payments @molecule/api-payments-stripe @molecule/api-pdf @molecule/api-pdf-pdfkit @molecule/api-permissions @molecule/api-permissions-custom @molecule/api-push-capture @molecule/api-push-notifications @molecule/api-push-notifications-web-push @molecule/api-queue @molecule/api-queue-memory @molecule/api-queue-redis @molecule/api-rate-limit @molecule/api-rate-limit-memory @molecule/api-realtime @molecule/api-realtime-socketio @molecule/api-realtime-sse @molecule/api-realtime-ws @molecule/api-reporting @molecule/api-reporting-database @molecule/api-resource @molecule/api-resource-device @molecule/api-resource-payment @molecule/api-resource-user @molecule/api-search @molecule/api-search-meilisearch @molecule/api-search-postgres @molecule/api-secrets @molecule/api-secrets-env @molecule/api-server-default-express @molecule/api-two-factor @molecule/api-two-factor-otplib @molecule/api-uploads @molecule/api-uploads-filesystem @molecule/api-uploads-s3 @molecule/api-webhook @molecule/api-webhook-http @molecule/api-workflow @molecule/api-workflow-database express zod
82
+ npm install @molecule/api-bonds-default-express @molecule/api-ai-anthropic @molecule/api-ai-embeddings @molecule/api-ai-embeddings-openai @molecule/api-ai-openai @molecule/api-ai-speech @molecule/api-ai-speech-openai @molecule/api-ai-vector-store @molecule/api-ai-vector-store-pgvector @molecule/api-analytics @molecule/api-audit @molecule/api-audit-database @molecule/api-bond @molecule/api-cache @molecule/api-cache-memory @molecule/api-cache-redis @molecule/api-config @molecule/api-config-env @molecule/api-cron @molecule/api-cron-node-cron @molecule/api-database @molecule/api-database-pglite @molecule/api-database-postgresql @molecule/api-emails @molecule/api-emails-capture @molecule/api-emails-mailgun @molecule/api-encryption @molecule/api-encryption-aes @molecule/api-entitlements @molecule/api-error-tracking @molecule/api-error-tracking-console @molecule/api-error-tracking-sentry @molecule/api-geolocation @molecule/api-geolocation-google @molecule/api-geolocation-mapbox @molecule/api-geolocation-nominatim @molecule/api-http @molecule/api-http-fetch @molecule/api-i18n @molecule/api-image @molecule/api-image-sharp @molecule/api-import-export @molecule/api-import-export-csv @molecule/api-jwt @molecule/api-jwt-jsonwebtoken @molecule/api-logger @molecule/api-media-streaming @molecule/api-media-streaming-hls @molecule/api-middleware-body-parser @molecule/api-middleware-body-parser-express @molecule/api-middleware-cookie-parser @molecule/api-middleware-cookie-parser-express @molecule/api-middleware-cors @molecule/api-middleware-cors-express @molecule/api-middleware-validation @molecule/api-notifications-webhook @molecule/api-password @molecule/api-password-bcrypt @molecule/api-payments @molecule/api-payments-capture @molecule/api-payments-stripe @molecule/api-pdf @molecule/api-pdf-pdfkit @molecule/api-permissions @molecule/api-permissions-custom @molecule/api-push-capture @molecule/api-push-notifications @molecule/api-push-notifications-web-push @molecule/api-queue @molecule/api-queue-memory @molecule/api-queue-redis @molecule/api-rate-limit @molecule/api-rate-limit-memory @molecule/api-realtime @molecule/api-realtime-socketio @molecule/api-realtime-sse @molecule/api-realtime-ws @molecule/api-reporting @molecule/api-reporting-database @molecule/api-resource @molecule/api-resource-device @molecule/api-resource-payment @molecule/api-resource-user @molecule/api-search @molecule/api-search-meilisearch @molecule/api-search-postgres @molecule/api-secrets @molecule/api-secrets-env @molecule/api-server-default-express @molecule/api-two-factor @molecule/api-two-factor-otplib @molecule/api-uploads @molecule/api-uploads-filesystem @molecule/api-uploads-s3 @molecule/api-webhook @molecule/api-webhook-http @molecule/api-workflow @molecule/api-workflow-database express zod
83
83
  npm install -D @types/express
84
84
  ```
85
85
 
@@ -124,6 +124,30 @@ function createMigrator(migrationsDir: string): () => Promise<void>
124
124
 
125
125
  **Returns:** A no-arg `runMigrations()` that creates the database (if missing) and applies every migration file in lexical order.
126
126
 
127
+ #### `createMigratorPglite(migrationsDir, extraDirs)`
128
+
129
+ Returns a `runMigrations()` that applies every `*.sql` file in
130
+ `migrationsDir`, in lexical order, to `@molecule/api-database-pglite`'s
131
+ default pool — the pool `setupDatabasePglite()` bonds, so the schema
132
+ lands in the database the app queries (an in-memory PGlite database exists
133
+ only inside that one instance). Same files and same "already exists is a
134
+ warning, anything else fails the boot" contract as `createMigrator`; there
135
+ is no `CREATE DATABASE` step.
136
+
137
+ Further directories run after it, each in its own lexical order — e.g. a
138
+ scaffolded app's `__setup__/` (resource-package DDL such as `payments.sql`)
139
+ after `migrations/`, the order the scaffolded Postgres runner uses. A
140
+ directory that does not exist counts as empty.
141
+
142
+ ```typescript
143
+ function createMigratorPglite(migrationsDir: string, extraDirs?: string[]): () => Promise<void>
144
+ ```
145
+
146
+ - `migrationsDir` — Absolute path to the app's `migrations/` directory.
147
+ - `extraDirs` — Absolute paths of further `*.sql` directories to apply after it, in order.
148
+
149
+ **Returns:** A no-arg migration runner.
150
+
127
151
  #### `getParamId(req, name?)`
128
152
 
129
153
  Read a route param as a string, defending against the Express
@@ -419,6 +443,27 @@ Wires `@molecule/api-cron-node-cron` to `@molecule/api-cron`.
419
443
  function setupCronNodeCron(): Promise<void>
420
444
  ```
421
445
 
446
+ #### `setupDatabasePglite()`
447
+
448
+ Wires `@molecule/api-database-pglite` (real Postgres compiled to
449
+ WebAssembly, in-process) to `@molecule/api-database` — the database half of
450
+ the zero-server "browser" profile. Same SQL, placeholders and error codes as
451
+ the postgresql bond, so app code and migrations do not change.
452
+
453
+ Binds the pglite package's DEFAULT pool, whose data directory comes from
454
+ `PGLITE_DATA_DIR` (`memory://`, `idb://<name>`, or a filesystem path; the
455
+ bond's Node default is `./data/pglite`). Run migrations with
456
+ {@link createMigratorPglite}, which targets the same default pool — an
457
+ in-memory database exists only inside that one instance, so the migrator
458
+ and the app must share it.
459
+
460
+ `@molecule/api-database-pglite` is an OPTIONAL peer, imported lazily, so a
461
+ postgres-only app never needs it installed.
462
+
463
+ ```typescript
464
+ function setupDatabasePglite(): Promise<void>
465
+ ```
466
+
422
467
  #### `setupDatabasePostgresql()`
423
468
 
424
469
  Wires `@molecule/api-database-postgresql` to `@molecule/api-database`.
@@ -427,6 +472,18 @@ Wires `@molecule/api-database-postgresql` to `@molecule/api-database`.
427
472
  function setupDatabasePostgresql(): void
428
473
  ```
429
474
 
475
+ #### `setupEmailsCapture()`
476
+
477
+ Wires `@molecule/api-emails-capture` to `@molecule/api-emails`
478
+ unconditionally — every message is captured in memory instead of sent.
479
+ Unlike {@link setupEmailsMailgun}'s development fallback, this does not
480
+ depend on `NODE_ENV` or on which env vars are missing, so a profile that
481
+ selects it always gets it.
482
+
483
+ ```typescript
484
+ function setupEmailsCapture(): void
485
+ ```
486
+
430
487
  #### `setupEmailsMailgun()`
431
488
 
432
489
  Wires `@molecule/api-emails-mailgun` to `@molecule/api-emails`.
@@ -562,6 +619,22 @@ Wires `@molecule/api-password-bcrypt` to `@molecule/api-password`.
562
619
  function setupPasswordBcrypt(): void
563
620
  ```
564
621
 
622
+ #### `setupPaymentsCapture()`
623
+
624
+ Registers `@molecule/api-payments-capture` (a payments vendor simulated in
625
+ memory: checkouts complete at once, signed local webhooks) under the name
626
+ `'stripe'` — the name {@link setupPaymentsStripe} uses — so the billing
627
+ router, the `/users/:id/verify-payment/stripe` and
628
+ `/users/payment-notification/stripe` routes, and the plan catalogue's
629
+ `platformKey` work unchanged. Grants plans without taking money: bond it in
630
+ a development / browser profile only, never in production.
631
+
632
+ `@molecule/api-payments-capture` is an OPTIONAL peer, imported lazily.
633
+
634
+ ```typescript
635
+ function setupPaymentsCapture(): Promise<void>
636
+ ```
637
+
565
638
  #### `setupPaymentsStripe()`
566
639
 
567
640
  Registers `@molecule/api-payments-stripe` as a named `'stripe'` payments provider.
@@ -835,6 +908,7 @@ Peer dependencies:
835
908
  - `@molecule/api-cron` ^1.0.1
836
909
  - `@molecule/api-cron-node-cron` ^1.0.1
837
910
  - `@molecule/api-database` ^1.0.1
911
+ - `@molecule/api-database-pglite` ^1.0.0
838
912
  - `@molecule/api-database-postgresql` ^1.0.1
839
913
  - `@molecule/api-emails` ^1.0.1
840
914
  - `@molecule/api-emails-capture` ^1.0.1
@@ -872,6 +946,7 @@ Peer dependencies:
872
946
  - `@molecule/api-password` ^1.0.1
873
947
  - `@molecule/api-password-bcrypt` ^1.0.1
874
948
  - `@molecule/api-payments` ^1.0.1
949
+ - `@molecule/api-payments-capture` ^1.0.0
875
950
  - `@molecule/api-payments-stripe` ^1.0.1
876
951
  - `@molecule/api-pdf` ^1.0.1
877
952
  - `@molecule/api-pdf-pdfkit` ^1.0.1
@@ -934,6 +1009,7 @@ Peer dependencies:
934
1009
  - `@molecule/api-cron`
935
1010
  - `@molecule/api-cron-node-cron`
936
1011
  - `@molecule/api-database`
1012
+ - `@molecule/api-database-pglite`
937
1013
  - `@molecule/api-database-postgresql`
938
1014
  - `@molecule/api-emails`
939
1015
  - `@molecule/api-emails-capture`
@@ -971,6 +1047,7 @@ Peer dependencies:
971
1047
  - `@molecule/api-password`
972
1048
  - `@molecule/api-password-bcrypt`
973
1049
  - `@molecule/api-payments`
1050
+ - `@molecule/api-payments-capture`
974
1051
  - `@molecule/api-payments-stripe`
975
1052
  - `@molecule/api-pdf`
976
1053
  - `@molecule/api-pdf-pdfkit`
package/dist/migrate.d.ts CHANGED
@@ -1,17 +1,38 @@
1
1
  /**
2
- * Postgres migration runner factory — re-exported from the PostgreSQL
3
- * bond.
2
+ * Migration runner factories.
4
3
  *
5
- * The `createMigrator` implementation lives in
6
- * `@molecule/api-database-postgresql` because it is Postgres-specific
7
- * bootstrapping plumbing (`CREATE DATABASE`, the `pg_database` catalog
8
- * probe, raw `pg.Client` connections). This bond-setup package must not
9
- * import the concrete `pg` driver directly — it reaches Postgres only
10
- * through the `@molecule/api-database-postgresql` bond it already
11
- * peer-depends on. App `scripts/migrate.ts` files keep importing
4
+ * `createMigrator` (Postgres) is re-exported from the PostgreSQL bond: it is
5
+ * Postgres-specific bootstrapping plumbing (`CREATE DATABASE`, the
6
+ * `pg_database` catalog probe, raw `pg.Client` connections), and this
7
+ * bond-setup package must not import the concrete `pg` driver directly — it
8
+ * reaches Postgres only through the `@molecule/api-database-postgresql` bond
9
+ * it already peer-depends on. App `scripts/migrate.ts` files keep importing
12
10
  * `createMigrator` from here unchanged.
13
11
  *
12
+ * `createMigratorPglite` is the same contract for the PGlite bond (the
13
+ * zero-server "browser" profile), loaded lazily because that bond is an
14
+ * optional peer.
15
+ *
14
16
  * @module
15
17
  */
16
18
  export { createMigrator } from '@molecule/api-database-postgresql';
19
+ /**
20
+ * Returns a `runMigrations()` that applies every `*.sql` file in
21
+ * `migrationsDir`, in lexical order, to `@molecule/api-database-pglite`'s
22
+ * default pool — the pool `setupDatabasePglite()` bonds, so the schema
23
+ * lands in the database the app queries (an in-memory PGlite database exists
24
+ * only inside that one instance). Same files and same "already exists is a
25
+ * warning, anything else fails the boot" contract as `createMigrator`; there
26
+ * is no `CREATE DATABASE` step.
27
+ *
28
+ * Further directories run after it, each in its own lexical order — e.g. a
29
+ * scaffolded app's `__setup__/` (resource-package DDL such as `payments.sql`)
30
+ * after `migrations/`, the order the scaffolded Postgres runner uses. A
31
+ * directory that does not exist counts as empty.
32
+ *
33
+ * @param migrationsDir - Absolute path to the app's `migrations/` directory.
34
+ * @param extraDirs - Absolute paths of further `*.sql` directories to apply after it, in order.
35
+ * @returns A no-arg migration runner.
36
+ */
37
+ export declare function createMigratorPglite(migrationsDir: string, ...extraDirs: string[]): () => Promise<void>;
17
38
  //# sourceMappingURL=migrate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA"}
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,GAAG,SAAS,EAAE,MAAM,EAAE,GACrB,MAAM,OAAO,CAAC,IAAI,CAAC,CAOrB"}
package/dist/migrate.js CHANGED
@@ -1,16 +1,44 @@
1
1
  /**
2
- * Postgres migration runner factory — re-exported from the PostgreSQL
3
- * bond.
2
+ * Migration runner factories.
4
3
  *
5
- * The `createMigrator` implementation lives in
6
- * `@molecule/api-database-postgresql` because it is Postgres-specific
7
- * bootstrapping plumbing (`CREATE DATABASE`, the `pg_database` catalog
8
- * probe, raw `pg.Client` connections). This bond-setup package must not
9
- * import the concrete `pg` driver directly — it reaches Postgres only
10
- * through the `@molecule/api-database-postgresql` bond it already
11
- * peer-depends on. App `scripts/migrate.ts` files keep importing
4
+ * `createMigrator` (Postgres) is re-exported from the PostgreSQL bond: it is
5
+ * Postgres-specific bootstrapping plumbing (`CREATE DATABASE`, the
6
+ * `pg_database` catalog probe, raw `pg.Client` connections), and this
7
+ * bond-setup package must not import the concrete `pg` driver directly — it
8
+ * reaches Postgres only through the `@molecule/api-database-postgresql` bond
9
+ * it already peer-depends on. App `scripts/migrate.ts` files keep importing
12
10
  * `createMigrator` from here unchanged.
13
11
  *
12
+ * `createMigratorPglite` is the same contract for the PGlite bond (the
13
+ * zero-server "browser" profile), loaded lazily because that bond is an
14
+ * optional peer.
15
+ *
14
16
  * @module
15
17
  */
16
18
  export { createMigrator } from '@molecule/api-database-postgresql';
19
+ /**
20
+ * Returns a `runMigrations()` that applies every `*.sql` file in
21
+ * `migrationsDir`, in lexical order, to `@molecule/api-database-pglite`'s
22
+ * default pool — the pool `setupDatabasePglite()` bonds, so the schema
23
+ * lands in the database the app queries (an in-memory PGlite database exists
24
+ * only inside that one instance). Same files and same "already exists is a
25
+ * warning, anything else fails the boot" contract as `createMigrator`; there
26
+ * is no `CREATE DATABASE` step.
27
+ *
28
+ * Further directories run after it, each in its own lexical order — e.g. a
29
+ * scaffolded app's `__setup__/` (resource-package DDL such as `payments.sql`)
30
+ * after `migrations/`, the order the scaffolded Postgres runner uses. A
31
+ * directory that does not exist counts as empty.
32
+ *
33
+ * @param migrationsDir - Absolute path to the app's `migrations/` directory.
34
+ * @param extraDirs - Absolute paths of further `*.sql` directories to apply after it, in order.
35
+ * @returns A no-arg migration runner.
36
+ */
37
+ export function createMigratorPglite(migrationsDir, ...extraDirs) {
38
+ return async function runMigrations() {
39
+ const { createMigrator: createPgliteMigrator } = await import('@molecule/api-database-pglite');
40
+ for (const dir of [migrationsDir, ...extraDirs]) {
41
+ await createPgliteMigrator(dir)();
42
+ }
43
+ };
44
+ }
package/dist/setup.d.ts CHANGED
@@ -14,6 +14,23 @@
14
14
  export declare function setupConfigEnv(): void;
15
15
  /** Wires `@molecule/api-database-postgresql` to `@molecule/api-database`. */
16
16
  export declare function setupDatabasePostgresql(): void;
17
+ /**
18
+ * Wires `@molecule/api-database-pglite` (real Postgres compiled to
19
+ * WebAssembly, in-process) to `@molecule/api-database` — the database half of
20
+ * the zero-server "browser" profile. Same SQL, placeholders and error codes as
21
+ * the postgresql bond, so app code and migrations do not change.
22
+ *
23
+ * Binds the pglite package's DEFAULT pool, whose data directory comes from
24
+ * `PGLITE_DATA_DIR` (`memory://`, `idb://<name>`, or a filesystem path; the
25
+ * bond's Node default is `./data/pglite`). Run migrations with
26
+ * {@link createMigratorPglite}, which targets the same default pool — an
27
+ * in-memory database exists only inside that one instance, so the migrator
28
+ * and the app must share it.
29
+ *
30
+ * `@molecule/api-database-pglite` is an OPTIONAL peer, imported lazily, so a
31
+ * postgres-only app never needs it installed.
32
+ */
33
+ export declare function setupDatabasePglite(): Promise<void>;
17
34
  /** Wires `@molecule/api-jwt-jsonwebtoken` to `@molecule/api-jwt`. */
18
35
  export declare function setupJwtJsonwebtoken(): void;
19
36
  /** Wires `@molecule/api-middleware-body-parser-express` to `@molecule/api-middleware-body-parser`. */
@@ -32,8 +49,28 @@ export declare function setupServiceDevice(): void;
32
49
  export declare function setupTwoFactorOtplib(): void;
33
50
  /** Wires `@molecule/api-emails-mailgun` to `@molecule/api-emails`. */
34
51
  export declare function setupEmailsMailgun(): void;
52
+ /**
53
+ * Wires `@molecule/api-emails-capture` to `@molecule/api-emails`
54
+ * unconditionally — every message is captured in memory instead of sent.
55
+ * Unlike {@link setupEmailsMailgun}'s development fallback, this does not
56
+ * depend on `NODE_ENV` or on which env vars are missing, so a profile that
57
+ * selects it always gets it.
58
+ */
59
+ export declare function setupEmailsCapture(): void;
35
60
  /** Registers `@molecule/api-payments-stripe` as a named `'stripe'` payments provider. */
36
61
  export declare function setupPaymentsStripe(): void;
62
+ /**
63
+ * Registers `@molecule/api-payments-capture` (a payments vendor simulated in
64
+ * memory: checkouts complete at once, signed local webhooks) under the name
65
+ * `'stripe'` — the name {@link setupPaymentsStripe} uses — so the billing
66
+ * router, the `/users/:id/verify-payment/stripe` and
67
+ * `/users/payment-notification/stripe` routes, and the plan catalogue's
68
+ * `platformKey` work unchanged. Grants plans without taking money: bond it in
69
+ * a development / browser profile only, never in production.
70
+ *
71
+ * `@molecule/api-payments-capture` is an OPTIONAL peer, imported lazily.
72
+ */
73
+ export declare function setupPaymentsCapture(): Promise<void>;
37
74
  /** Registers the plan + paymentRecord services from `@molecule/api-resource-payment`. */
38
75
  export declare function setupServicePayment(): void;
39
76
  /** Wires `@molecule/api-search-meilisearch` to `@molecule/api-search`. */
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoEH,kEAAkE;AAClE,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,sGAAsG;AACtG,wBAAgB,gCAAgC,IAAI,IAAI,CAGvD;AAED,0GAA0G;AAC1G,wBAAgB,kCAAkC,IAAI,IAAI,CAGzD;AAED,wFAAwF;AACxF,w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AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM1D"}
package/dist/setup.js CHANGED
@@ -73,6 +73,27 @@ export function setupDatabasePostgresql() {
73
73
  setPool(dbPool);
74
74
  setStore(dbStore);
75
75
  }
76
+ /**
77
+ * Wires `@molecule/api-database-pglite` (real Postgres compiled to
78
+ * WebAssembly, in-process) to `@molecule/api-database` — the database half of
79
+ * the zero-server "browser" profile. Same SQL, placeholders and error codes as
80
+ * the postgresql bond, so app code and migrations do not change.
81
+ *
82
+ * Binds the pglite package's DEFAULT pool, whose data directory comes from
83
+ * `PGLITE_DATA_DIR` (`memory://`, `idb://<name>`, or a filesystem path; the
84
+ * bond's Node default is `./data/pglite`). Run migrations with
85
+ * {@link createMigratorPglite}, which targets the same default pool — an
86
+ * in-memory database exists only inside that one instance, so the migrator
87
+ * and the app must share it.
88
+ *
89
+ * `@molecule/api-database-pglite` is an OPTIONAL peer, imported lazily, so a
90
+ * postgres-only app never needs it installed.
91
+ */
92
+ export async function setupDatabasePglite() {
93
+ const { pool, store } = await import('@molecule/api-database-pglite');
94
+ setPool(pool);
95
+ setStore(store);
96
+ }
76
97
  /** Wires `@molecule/api-jwt-jsonwebtoken` to `@molecule/api-jwt`. */
77
98
  export function setupJwtJsonwebtoken() {
78
99
  setJwt(jwtProvider);
@@ -117,10 +138,35 @@ export function setupEmailsMailgun() {
117
138
  }
118
139
  setEmails(emailsMailgunProvider);
119
140
  }
141
+ /**
142
+ * Wires `@molecule/api-emails-capture` to `@molecule/api-emails`
143
+ * unconditionally — every message is captured in memory instead of sent.
144
+ * Unlike {@link setupEmailsMailgun}'s development fallback, this does not
145
+ * depend on `NODE_ENV` or on which env vars are missing, so a profile that
146
+ * selects it always gets it.
147
+ */
148
+ export function setupEmailsCapture() {
149
+ setEmails(emailsCaptureProvider);
150
+ }
120
151
  /** Registers `@molecule/api-payments-stripe` as a named `'stripe'` payments provider. */
121
152
  export function setupPaymentsStripe() {
122
153
  bond('payments', 'stripe', stripePaymentProvider);
123
154
  }
155
+ /**
156
+ * Registers `@molecule/api-payments-capture` (a payments vendor simulated in
157
+ * memory: checkouts complete at once, signed local webhooks) under the name
158
+ * `'stripe'` — the name {@link setupPaymentsStripe} uses — so the billing
159
+ * router, the `/users/:id/verify-payment/stripe` and
160
+ * `/users/payment-notification/stripe` routes, and the plan catalogue's
161
+ * `platformKey` work unchanged. Grants plans without taking money: bond it in
162
+ * a development / browser profile only, never in production.
163
+ *
164
+ * `@molecule/api-payments-capture` is an OPTIONAL peer, imported lazily.
165
+ */
166
+ export async function setupPaymentsCapture() {
167
+ const { provider } = await import('@molecule/api-payments-capture');
168
+ bond('payments', 'stripe', provider);
169
+ }
124
170
  /** Registers the plan + paymentRecord services from `@molecule/api-resource-payment`. */
125
171
  export function setupServicePayment() {
126
172
  bond('plans', planService);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-bonds-default-express",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Default API bond setup for Express-based apps. Provides setup functions for the 10 byte-identical bond wirings shared across the molecule fleet — config-env, database-postgresql, jwt-jsonwebtoken, middleware-{body-parser,cookie-parser,cors}-express, password-bcrypt, secrets-env, service-device, two-factor-otplib.",
5
5
  "homepage": "https://www.molecule.dev/packages/api-bonds-default-express",
6
6
  "dependencies": {
@@ -57,6 +57,7 @@
57
57
  "@molecule/api-cron": "1.0.3",
58
58
  "@molecule/api-cron-node-cron": "1.0.2",
59
59
  "@molecule/api-database": "1.0.2",
60
+ "@molecule/api-database-pglite": "1.0.0",
60
61
  "@molecule/api-database-postgresql": "1.0.5",
61
62
  "@molecule/api-emails": "1.0.2",
62
63
  "@molecule/api-emails-capture": "1.0.3",
@@ -75,7 +76,7 @@
75
76
  "@molecule/api-http-fetch": "1.0.2",
76
77
  "@molecule/api-i18n": "1.0.3",
77
78
  "@molecule/api-image": "1.0.2",
78
- "@molecule/api-image-sharp": "1.0.3",
79
+ "@molecule/api-image-sharp": "1.0.4",
79
80
  "@molecule/api-import-export": "1.0.3",
80
81
  "@molecule/api-import-export-csv": "1.0.2",
81
82
  "@molecule/api-jwt": "1.0.3",
@@ -94,6 +95,7 @@
94
95
  "@molecule/api-password": "1.0.2",
95
96
  "@molecule/api-password-bcrypt": "1.0.3",
96
97
  "@molecule/api-payments": "1.2.1",
98
+ "@molecule/api-payments-capture": "1.0.0",
97
99
  "@molecule/api-payments-stripe": "1.2.6",
98
100
  "@molecule/api-pdf": "1.0.2",
99
101
  "@molecule/api-pdf-pdfkit": "1.0.2",
@@ -159,6 +161,7 @@
159
161
  "@molecule/api-cron": "^1.0.1",
160
162
  "@molecule/api-cron-node-cron": "^1.0.1",
161
163
  "@molecule/api-database": "^1.0.1",
164
+ "@molecule/api-database-pglite": "^1.0.0",
162
165
  "@molecule/api-database-postgresql": "^1.0.1",
163
166
  "@molecule/api-emails": "^1.0.1",
164
167
  "@molecule/api-emails-capture": "^1.0.1",
@@ -196,6 +199,7 @@
196
199
  "@molecule/api-password": "^1.0.1",
197
200
  "@molecule/api-password-bcrypt": "^1.0.1",
198
201
  "@molecule/api-payments": "^1.0.1",
202
+ "@molecule/api-payments-capture": "^1.0.0",
199
203
  "@molecule/api-payments-stripe": "^1.0.1",
200
204
  "@molecule/api-pdf": "^1.0.1",
201
205
  "@molecule/api-pdf-pdfkit": "^1.0.1",
@@ -386,6 +390,12 @@
386
390
  },
387
391
  "@molecule/api-media-streaming-hls": {
388
392
  "optional": true
393
+ },
394
+ "@molecule/api-database-pglite": {
395
+ "optional": true
396
+ },
397
+ "@molecule/api-payments-capture": {
398
+ "optional": true
389
399
  }
390
400
  }
391
401
  }