added a few initial plugins

This commit is contained in:
dswbx
2025-06-12 19:58:18 +02:00
parent fe5ccd4206
commit 8517c9b90b
12 changed files with 125 additions and 8 deletions
+35
View File
@@ -0,0 +1,35 @@
import { App, type AppConfig, type AppPlugin } from "bknd";
export type SyncConfigOptions = {
enabled?: boolean;
includeSecrets?: boolean;
write: (config: AppConfig) => Promise<void>;
};
export function syncConfig({
enabled = true,
includeSecrets = false,
write,
}: SyncConfigOptions): AppPlugin {
let firstBoot = true;
return (app: App) => ({
name: "bknd-sync-config",
onBuilt: async () => {
if (!enabled) return;
app.emgr.onEvent(
App.Events.AppConfigUpdatedEvent,
async () => {
await write?.(app.toJSON(includeSecrets));
},
{
id: "sync-config",
},
);
if (firstBoot) {
firstBoot = false;
await write?.(app.toJSON(true));
}
},
});
}