@bractjs/bractjs 0.1.17 → 0.1.19
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/package.json +1 -1
- package/src/dev/server.ts +2 -1
- package/src/server/serve.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bractjs/bractjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Production-grade SSR framework for Bun + React 19. File-based routing, streaming SSR, server actions, typed routes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/bractjs/bractjs#readme",
|
package/src/dev/server.ts
CHANGED
|
@@ -20,7 +20,8 @@ console.log(`[bractjs] initial client build in ${initialMs}ms`);
|
|
|
20
20
|
// Load user lifecycle hooks if defined (e.g. app/lifecycle.ts)
|
|
21
21
|
let lifecycle: LifecycleHooks = {};
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
23
|
+
const lifecyclePath = `${process.cwd()}/app/lifecycle.ts`;
|
|
24
|
+
const mod = await import(lifecyclePath);
|
|
24
25
|
if (mod.default) lifecycle = mod.default;
|
|
25
26
|
} catch {
|
|
26
27
|
// No lifecycle file — that's fine
|
package/src/server/serve.ts
CHANGED
|
@@ -183,6 +183,7 @@ async function warnIfStaleBuild(buildDir: string): Promise<void> {
|
|
|
183
183
|
// HMR restarts and multiple createServer() calls in the same process.
|
|
184
184
|
let signalsRegistered = false;
|
|
185
185
|
let isShuttingDown = false;
|
|
186
|
+
let activeOnShutdown: (() => Promise<void> | void) | undefined;
|
|
186
187
|
|
|
187
188
|
export function createServer(config?: Partial<BractJSConfig>): {
|
|
188
189
|
stop(): void;
|
|
@@ -209,6 +210,8 @@ export function createServer(config?: Partial<BractJSConfig>): {
|
|
|
209
210
|
adapter.listen?.(port);
|
|
210
211
|
}
|
|
211
212
|
|
|
213
|
+
activeOnShutdown = config?.onShutdown;
|
|
214
|
+
|
|
212
215
|
console.log(`[bract] Server running at http://localhost:${port}`);
|
|
213
216
|
|
|
214
217
|
const stopAdapter = () => {
|
|
@@ -224,7 +227,7 @@ export function createServer(config?: Partial<BractJSConfig>): {
|
|
|
224
227
|
isShuttingDown = true;
|
|
225
228
|
if (signal) console.log(`\n[bract] Received ${signal}, shutting down…`);
|
|
226
229
|
try {
|
|
227
|
-
await
|
|
230
|
+
await activeOnShutdown?.();
|
|
228
231
|
} catch (err) {
|
|
229
232
|
console.error("[bract] onShutdown error:", err);
|
|
230
233
|
}
|