Ben Senescu abc80e1e2b
Fix server-fn deprecation warnings and add CSRF middleware (#357)
* Replace deprecated createServerFn().inputValidator() with .validator()

* Add CSRF middleware for server functions

* Fix prettier formatting after validator rename

* Pass Zod schemas directly to .validator()

Drops the (data: unknown) => schema.parse(data) lambdas in favor of
standard-schema support. This also makes server-fn callers type-checked
against the schema input, which surfaced a dead hideSpam property in
SearchTabStrip (the schema never included it and the server hard-codes
hideSpam for web requests).

* Name the inline project-scoped schema in projects.ts
2026-07-05 20:18:12 -04:00

12 lines
405 B
TypeScript

import { createCsrfMiddleware, createStart } from "@tanstack/react-start";
import { globalServerFunctionMiddleware } from "@/serverFunctions/middleware";
const csrfMiddleware = createCsrfMiddleware({
filter: (ctx) => ctx.handlerType === "serverFn",
});
export const startInstance = createStart(() => ({
requestMiddleware: [csrfMiddleware],
functionMiddleware: globalServerFunctionMiddleware,
}));