2026-08-19 19:00:29 +07:00
|
|
|
import { initTRPC } from "@trpc/server";
|
|
|
|
|
import { db } from "@mcpedia/db";
|
|
|
|
|
|
|
|
|
|
export interface Context {
|
|
|
|
|
db: typeof db;
|
2026-08-20 09:53:33 +07:00
|
|
|
// Raw `x-webhook-secret` header from the incoming request, if present.
|
2026-08-20 13:08:27 +07:00
|
|
|
// State-changing tRPC mutations (restoreRevision, CRUD) require it to match
|
|
|
|
|
// the configured secret; read-only procedures ignore it.
|
2026-08-20 09:53:33 +07:00
|
|
|
webhookSecret?: string;
|
2026-08-20 13:08:27 +07:00
|
|
|
// The configured expected secret (from deps). Used by requireWriteAuth
|
|
|
|
|
// to validate the header — request-scoped so tests can inject a fake.
|
|
|
|
|
expectedSecret: string;
|
2026-08-19 19:00:29 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const t = initTRPC.context<Context>().create();
|
|
|
|
|
|
|
|
|
|
export const router = t.router;
|
|
|
|
|
export const publicProcedure = t.procedure;
|