init
This commit is contained in:
19
src/routes/api/trpc/[trpc].ts
Normal file
19
src/routes/api/trpc/[trpc].ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { APIEvent } from "@solidjs/start/server";
|
||||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
||||
import { appRouter } from "~/server/api/root";
|
||||
|
||||
const handler = (event: APIEvent) =>
|
||||
// adapts tRPC to fetch API style requests
|
||||
fetchRequestHandler({
|
||||
// the endpoint handling the requests
|
||||
endpoint: "/api/trpc",
|
||||
// the request object
|
||||
req: event.request,
|
||||
// the router for handling the requests
|
||||
router: appRouter,
|
||||
// any arbitrary data that should be available to all actions
|
||||
createContext: () => event
|
||||
});
|
||||
|
||||
export const GET = handler;
|
||||
export const POST = handler;
|
||||
Reference in New Issue
Block a user