@cadenza.io/service 2.15.0 → 2.17.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 +46 -0
- package/dist/browser/index.js +8005 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/index.mjs +7978 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/index.d.mts +196 -22
- package/dist/index.d.ts +196 -22
- package/dist/index.js +1521 -476
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1515 -472
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -41,6 +41,52 @@ import Cadenza from '@cadenza.io/service';
|
|
|
41
41
|
Cadenza.createCadenzaService('MyService'); // Name should start with an uppercase letter and contain no spaces.
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
### Creating a frontend runtime
|
|
45
|
+
Frontend mode keeps the same package and distributed primitives, but disables Node-only features such as REST/socket server creation, PostgresActors, and database-service bootstrapping.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import Cadenza from '@cadenza.io/service';
|
|
49
|
+
|
|
50
|
+
Cadenza.createCadenzaService('BrowserApp', 'Frontend app', {
|
|
51
|
+
isFrontend: true,
|
|
52
|
+
bootstrap: {
|
|
53
|
+
url: 'https://cadenza-db.example.com:5000',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Frontend bootstrap resolution order is:
|
|
59
|
+
|
|
60
|
+
1. `options.bootstrap.url`
|
|
61
|
+
2. `globalThis.__CADENZA_RUNTIME__.bootstrapUrl`
|
|
62
|
+
3. `CADENZA_DB_ADDRESS` plus optional `CADENZA_DB_PORT` on the server side
|
|
63
|
+
|
|
64
|
+
`CADENZA_DB_ADDRESS` now accepts either a full address with port, or a bare host/address when `CADENZA_DB_PORT` is also set.
|
|
65
|
+
|
|
66
|
+
### SSR inquiries
|
|
67
|
+
For SSR use cases, use the request-scoped bridge for one-off distributed inquiries and pass dehydrated results to the browser runtime.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import {
|
|
71
|
+
createSSRInquiryBridge,
|
|
72
|
+
type HydrationOptions,
|
|
73
|
+
} from '@cadenza.io/service';
|
|
74
|
+
|
|
75
|
+
const bridge = createSSRInquiryBridge({
|
|
76
|
+
bootstrap: {
|
|
77
|
+
url: process.env.CADENZA_DB_ADDRESS,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const users = await bridge.inquire(
|
|
82
|
+
'users-list',
|
|
83
|
+
{},
|
|
84
|
+
{ hydrationKey: 'users-list.initial' },
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const hydration: HydrationOptions = bridge.dehydrate();
|
|
88
|
+
```
|
|
89
|
+
|
|
44
90
|
### Working with distribution
|
|
45
91
|
Distribution is easy with Cadenza. You can delegate the flow by using a DeputyTask, or subscribe to foreign signals by prefixing them with the service name.
|
|
46
92
|
|