import { Injectable } from '@nestjs/common'; import { TrpcService } from '@server/trpc/trpc.service'; import { DriverService } from './driver.service'; import { z, ZodType } from 'zod'; import { Prisma } from '@nice/common'; const CourseCreateArgsSchema: ZodType = z.any(); const CourseUpdateArgsSchema: ZodType = z.any(); const CourseFindManyArgsSchema: ZodType = z.any(); const CourseWhereUniqueInputSchema: ZodType = z.any(); @Injectable() export class DriverRouter { constructor( private readonly trpc: TrpcService, private readonly driverService: DriverService, ) {} router = this.trpc.router({ create: this.trpc.protectProcedure .input(CourseCreateArgsSchema) .mutation(async ({ input }) => { return await this.driverService.create(input); }), // update: this.trpc.protectProcedure // .input(CourseUpdateArgsSchema) // .mutation(async ({ input }) => { // return await this.driverService.update(input); // }), softDeleteByIds: this.trpc.protectProcedure .input( z.object({ ids: z.array(z.string()), data: CourseUpdateArgsSchema.nullish(), }), ) .mutation(async ({ input }) => { return await this.driverService.softDeleteByIds(input.ids); }), // delete: this.trpc.protectProcedure // .input(CourseWhereUniqueInputSchema) // .mutation(async ({ input }) => { // return await this.driverService.delete({ where: input }); // }), // findMany: this.trpc.procedure // .input(CourseFindManyArgsSchema) // .query(async ({ input }) => { // return await this.driverService.findMany(input); // }), findWithScores: this.trpc.procedure .input(z.number()) .query(async ({ input }) => { return await this.driverService.findWithScores(input); }), search: this.trpc.procedure .input(z.object({ name: z.string().optional(), courseId: z.number().optional(), limit: z.number().optional() })) .query(async ({ input }) => { return await this.driverService.search(input); }), }); }