mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-15 15:26:59 +10:00
b7e4c86f4e
* Harden security, health checks, and dependency hygiene Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * Finalize health and storage hardening adjustments Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * remove use of [REDACTED] * update dependencies --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { onError } from "@orpc/server";
|
|
import { RPCHandler } from "@orpc/server/fetch";
|
|
import { BatchHandlerPlugin, RequestHeadersPlugin, StrictGetMethodPlugin } from "@orpc/server/plugins";
|
|
import { createFileRoute } from "@tanstack/react-router";
|
|
import router from "@/integrations/orpc/router";
|
|
import { getLocale } from "@/utils/locale";
|
|
import { logger } from "@/utils/logger";
|
|
|
|
const rpcHandler = new RPCHandler(router, {
|
|
plugins: [new BatchHandlerPlugin(), new RequestHeadersPlugin(), new StrictGetMethodPlugin()],
|
|
interceptors: [
|
|
onError((error) => {
|
|
logger.error("oRPC server error", {
|
|
route: "/api/rpc",
|
|
error,
|
|
});
|
|
}),
|
|
],
|
|
});
|
|
|
|
async function handler({ request }: { request: Request }) {
|
|
const { response } = await rpcHandler.handle(request, {
|
|
prefix: "/api/rpc",
|
|
context: { locale: await getLocale() },
|
|
});
|
|
|
|
if (!response) return new Response("NOT_FOUND", { status: 404 });
|
|
|
|
return response;
|
|
}
|
|
|
|
export const Route = createFileRoute("/api/rpc/$")({
|
|
server: {
|
|
handlers: {
|
|
ANY: handler,
|
|
},
|
|
},
|
|
});
|