Give a plugin a Postgres database of its own

This commit is contained in:
2026-08-18 23:12:13 +02:00
parent 9ff8f57509
commit c7013be2f0
24 changed files with 524 additions and 48 deletions
+8 -4
View File
@@ -4,11 +4,15 @@
// entirely when no plugin declares the hook, so the no-hooks hot path stays free.
import type { RequestContext } from "../http/context.ts";
import type { Plugin, RouteResult } from "./plugin.ts";
import type { BootContext, Plugin, RouteResult } from "./plugin.ts";
// After discovery, before the server listens. A throw aborts boot.
export async function runBootHooks(plugins: Plugin[]): Promise<void> {
for (const plugin of plugins) await plugin.hooks?.onBoot?.();
// After discovery, before the server listens. A throw aborts boot. Each hook gets a context built
// for its own plugin, so one plugin is never handed another's storage credentials.
export async function runBootHooks(plugins: Plugin[], bootContextFor: (plugin: Plugin) => BootContext): Promise<void> {
for (const plugin of plugins) {
const onBoot = plugin.hooks?.onBoot;
if (onBoot) await onBoot(bootContextFor(plugin));
}
}
// Before route matching. The first hook to return a RouteResult short-circuits the request — its