@luckystack/server 0.8.6 → 0.9.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 +6 -0
- package/CLAUDE.md +3 -2
- package/dist/index.d.ts +25 -1
- package/dist/index.js +27 -15
- package/dist/index.js.map +1 -1
- package/docs/create-server.md +33 -0
- package/package.json +11 -11
package/docs/create-server.md
CHANGED
|
@@ -108,6 +108,39 @@ await server.listen();
|
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
+
### `afterListen(task, options?): Promise<void>`
|
|
112
|
+
|
|
113
|
+
Runs work that belongs **after** the server is accepting traffic — durable queue
|
|
114
|
+
workers, warm-up passes, reconciliation jobs.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
await server.listen();
|
|
118
|
+
|
|
119
|
+
await server.afterListen(async () => {
|
|
120
|
+
const { startWorkers } = await import('../src/jobs/workers');
|
|
121
|
+
await startWorkers();
|
|
122
|
+
}, { label: 'job workers' });
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Why it exists.** The scaffolded `server/server.ts` wraps its boot in an IIFE
|
|
126
|
+
whose `.catch` calls `process.exit(1)`. That is right for everything *before*
|
|
127
|
+
`listen()` — a failure there means there is no server. Appending post-listen work
|
|
128
|
+
to the same chain silently extends "fatal" to tasks that run while the server is
|
|
129
|
+
already serving, so one unreachable dependency (a queue's database, say) kills a
|
|
130
|
+
healthy process. Behind a supervisor that becomes a crash-loop: restart,
|
|
131
|
+
dependency still down, repeat — while the log claims `failed to start` about a
|
|
132
|
+
server that started fine.
|
|
133
|
+
|
|
134
|
+
| Option | Default | Effect |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| `fatal` | `false` | `true` re-throws instead of swallowing. Use only when the process genuinely has no purpose without the task. |
|
|
137
|
+
| `label` | `'post-listen task'` | Names the task in the failure log. |
|
|
138
|
+
|
|
139
|
+
Never resolves to the task's value — it is fire-and-report, not a pipeline stage.
|
|
140
|
+
Read whatever you need inside the callback.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
111
144
|
### `bootstrapLuckyStack(options?: BootstrapLuckyStackOptions): Promise<RunningLuckyStackServer>`
|
|
112
145
|
|
|
113
146
|
**Signature:**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luckystack/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"test": "vitest run"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@luckystack/api": "^0.
|
|
61
|
-
"@luckystack/core": "^0.
|
|
60
|
+
"@luckystack/api": "^0.9.0",
|
|
61
|
+
"@luckystack/core": "^0.9.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@prisma/client": "^6.19.0",
|
|
65
65
|
"socket.io": "^4.8.0",
|
|
66
|
-
"@luckystack/cron": "^0.
|
|
67
|
-
"@luckystack/devkit": "^0.
|
|
68
|
-
"@luckystack/docs-ui": "^0.
|
|
69
|
-
"@luckystack/email": "^0.
|
|
70
|
-
"@luckystack/error-tracking": "^0.
|
|
71
|
-
"@luckystack/login": "^0.
|
|
72
|
-
"@luckystack/presence": "^0.
|
|
73
|
-
"@luckystack/sync": "^0.
|
|
66
|
+
"@luckystack/cron": "^0.9.0",
|
|
67
|
+
"@luckystack/devkit": "^0.9.0",
|
|
68
|
+
"@luckystack/docs-ui": "^0.9.0",
|
|
69
|
+
"@luckystack/email": "^0.9.0",
|
|
70
|
+
"@luckystack/error-tracking": "^0.9.0",
|
|
71
|
+
"@luckystack/login": "^0.9.0",
|
|
72
|
+
"@luckystack/presence": "^0.9.0",
|
|
73
|
+
"@luckystack/sync": "^0.9.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependenciesMeta": {
|
|
76
76
|
"@prisma/client": {
|