push service

This commit is contained in:
toni
2026-03-13 21:54:43 +01:00
parent 71ca4d81e1
commit 29c6828dd1
23 changed files with 526 additions and 137 deletions
+12 -1
View File
@@ -1,6 +1,7 @@
import { PrismaPg } from "@prisma/adapter-pg";
import { type Request } from "express";
import { PrismaClient } from "../../generated/prisma/client.js";
import type { UserModel } from "../../generated/prisma/models.js";
import { Injectable } from "../../infrastructure/di/injectable-decorator.js";
type ExtendedClient = ReturnType<typeof createExtendedClient>;
@@ -23,7 +24,17 @@ export type SafeClient = Omit<
>;
function createExtendedClient(client: PrismaClient) {
return client;
return client.$extends({
client: {
async ensureUserKnown(userId: string): Promise<UserModel>{
let user = await client.user.findUnique({where: {id: userId}});
if(user==null){
user = await client.user.create({data:{id: userId}});
}
return user
}
}
});
// .$extends({
// name: "testExtension",
// model: {