From 0818d9828a138809bc0dd056c5e3f2e942e9a0b0 Mon Sep 17 00:00:00 2001 From: Kevin Puig <119972216+k-puig@users.noreply.github.com> Date: Sat, 27 Sep 2025 14:53:15 -0400 Subject: [PATCH] Update db schema + add hasher func --- concord-server/schema.prisma | 11 ++++------- concord-server/src/helper/hashing.ts | 5 +++++ concord-server/src/validators/userValidator.ts | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 concord-server/src/helper/hashing.ts diff --git a/concord-server/schema.prisma b/concord-server/schema.prisma index fc43e65..0e23b2a 100644 --- a/concord-server/schema.prisma +++ b/concord-server/schema.prisma @@ -56,7 +56,6 @@ model Category { name String position Int Channel Channel[] - Message Message[] } model Channel { @@ -71,12 +70,10 @@ model Channel { model Message { id String @id @default(uuid(7)) - Channel Channel? @relation(fields: [channelId], references: [id]) - channelId String? - Category Category? @relation(fields: [categoryId], references: [id]) - categoryId String? - User User? @relation(fields: [userId], references: [id]) - userId String? + Channel Channel @relation(fields: [channelId], references: [id]) + channelId String + User User @relation(fields: [userId], references: [id]) + userId String deleted Boolean text String replies Reply[] @relation("MessageToReply") diff --git a/concord-server/src/helper/hashing.ts b/concord-server/src/helper/hashing.ts new file mode 100644 index 0000000..cd4cb4f --- /dev/null +++ b/concord-server/src/helper/hashing.ts @@ -0,0 +1,5 @@ +import * as crypto from 'crypto'; + +export default function shaHash(data:string, salt:string) : string { + return crypto.createHmac('sha256', salt).update(data).digest('hex'); +} diff --git a/concord-server/src/validators/userValidator.ts b/concord-server/src/validators/userValidator.ts index a4aaa60..6837dd2 100644 --- a/concord-server/src/validators/userValidator.ts +++ b/concord-server/src/validators/userValidator.ts @@ -18,4 +18,6 @@ export const createUserSchema = z.object({ admin: z.boolean().default(false), }) +export type QueryUserByIdInput = z.infer +export type QueryAllUsersByInstanceIdInput = z.infer export type CreateUserInput = z.infer \ No newline at end of file