test setup lackin

This commit is contained in:
2025-09-03 22:04:56 +02:00
parent 869cc07fdd
commit 276c3dd75f
35 changed files with 629 additions and 285 deletions

View File

@@ -2,7 +2,7 @@
// import postgres from "postgres";
import { env } from "~/env";
import * as schema from "./schema";
import * as schema from "~/server/dbschema/schema";
// /**
// * Cache the database connection in development. This avoids creating a new connection on every HMR

View File

@@ -1,7 +1,7 @@
import type { Entries } from "type-fest";
import { publicProcedure, router } from "~/server/trpc";
import { db } from "~/server/db";
import * as schema from "~/server/db/schema";
import * as schema from '~/server/dbschema/schema';
import { isAdmin } from "~/app/actions";
import { TRPCError } from "@trpc/server";
import { entitySchemas, type Schema, type SchemaKeys } from "~/lib/utils";
@@ -20,6 +20,7 @@ export function trpcCrudRouterFromDrizzleEntity<T extends SchemaKeys<Schema>>(ta
}
let r = router({
select: publicProcedure.input(schemas.update).query(async (opts) => {
console.log("select with:", opts.input)
const { input } = opts;
if (input === undefined) {
return await db.select().from(schema[table]).execute();
@@ -36,6 +37,7 @@ export function trpcCrudRouterFromDrizzleEntity<T extends SchemaKeys<Schema>>(ta
return await db.select().from(schema[table]).execute();
}),
update: publicProcedure.input(schemas.update).mutation(async (opts) => {
console.log("update with:",opts.input)
let admin = await isAdmin();
if (!admin) {
throw new TRPCError(
@@ -52,6 +54,7 @@ export function trpcCrudRouterFromDrizzleEntity<T extends SchemaKeys<Schema>>(ta
return await db.update(schema[table]).set(input).where(eq(schema[table]['id'], input['id'])).returning().execute();
}),
insert: publicProcedure.input(schemas.insert).mutation(async (opts) => {
console.log("insert with:",opts.input)
let admin = await isAdmin();
if (!admin) {
throw new TRPCError(
@@ -62,6 +65,7 @@ export function trpcCrudRouterFromDrizzleEntity<T extends SchemaKeys<Schema>>(ta
return await db.insert(schema[table]).values(input).returning().execute();
}),
delete: publicProcedure.input(schemas.update).mutation(async (opts) => {
console.log("delete with:",opts.input)
let admin = await isAdmin();
if (!admin) {
throw new TRPCError(