chore(repo): initialize planarchy workspace

This commit is contained in:
2026-03-14 14:31:09 +01:00
commit dd55d0e78b
769 changed files with 166461 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import { createTRPCContext } from "@planarchy/api";
import { appRouter } from "@planarchy/api/router";
import { prisma } from "@planarchy/db";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import type { NextRequest } from "next/server";
import { auth } from "~/server/auth.js";
const handler = async (req: NextRequest) => {
const session = await auth();
const dbUser = session?.user?.email
? await prisma.user.findUnique({
where: { email: session.user.email },
select: { id: true, systemRole: true, permissionOverrides: true },
})
: null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options: any = {
endpoint: "/api/trpc",
req,
router: appRouter,
createContext: () => createTRPCContext({ session, dbUser }),
};
if (process.env["NODE_ENV"] === "development") {
options.onError = ({ path, error }: { path?: string; error: { message: string } }) => {
console.error(`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`);
};
}
return fetchRequestHandler(options);
};
export { handler as GET, handler as POST };