mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-20 17:13:49 +00:00
Whole-table writes and cached snapshots can overwrite other groups or resurrect removed configuration. Use per-group guarded writes, one-time identity migration and explicit unreadable-row failures.
14 lines
506 B
TypeScript
14 lines
506 B
TypeScript
import type { Env } from "../lib/types";
|
|
import { initConfigStore } from "../lib/config";
|
|
|
|
/**
|
|
* Bind the D1-backed configuration store before any handler runs, so no
|
|
* request path (invite acceptance, OAuth callbacks, bot commands, ...) can
|
|
* fall back to the KV-only store and read or write a configuration that
|
|
* diverges from D1.
|
|
*/
|
|
export default defineEventHandler((event) => {
|
|
const env = (event.context.cloudflare as { env?: Env } | undefined)?.env;
|
|
if (env?.KV) initConfigStore(env);
|
|
});
|