import { Injectable } from '@nestjs/common'; import { TrpcService } from '@server/trpc/trpc.service'; import { MessageService } from './message.service'; import { Prisma } from '@nice/common'; import { z, ZodType } from 'zod'; const MessageUncheckedCreateInputSchema: ZodType = z.any() const MessageWhereInputSchema: ZodType = z.any() const MessageSelectSchema: ZodType = z.any() @Injectable() export class MessageRouter { constructor( private readonly trpc: TrpcService, private readonly messageService: MessageService, ) { } router = this.trpc.router({ create: this.trpc.procedure .input(MessageUncheckedCreateInputSchema) .mutation(async ({ ctx, input }) => { const { staff } = ctx; return await this.messageService.create({ data: input }, { staff }); }), findManyWithCursor: this.trpc.protectProcedure .input(z.object({ cursor: z.any().nullish(), take: z.number().nullish(), where: MessageWhereInputSchema.nullish(), select: MessageSelectSchema.nullish() })) .query(async ({ ctx, input }) => { const { staff } = ctx; return await this.messageService.findManyWithCursor(input, staff); }), getUnreadCount: this.trpc.protectProcedure .query(async ({ ctx }) => { const { staff } = ctx; return await this.messageService.getUnreadCount(staff); }) }) }