feat: Remove ZodFilter and ZodPipe classes

The ZodFilter and ZodPipe classes located under src/pipes have been completely removed. This includes deletion of all features, methods, and imports associated with these classes.
This commit is contained in:
Mathis H (Avnyr) 2024-07-11 13:51:40 +02:00
parent 6905e8faee
commit ed19be6369
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
2 changed files with 0 additions and 30 deletions

View File

@ -1,17 +0,0 @@
import { ArgumentsHost, Catch, ExceptionFilter, HttpStatus } from "@nestjs/common";
import { ZodError } from "zod";
@Catch(ZodError)
export class ZodFilter<T extends ZodError> implements ExceptionFilter {
catch(exception: T, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse();
const status = HttpStatus.BAD_REQUEST;
response.status(status).json({
errors: exception.errors,
message: exception.message,
statusCode: status,
});
}
}

View File

@ -1,13 +0,0 @@
import { ArgumentMetadata, Injectable, PipeTransform } from "@nestjs/common";
import { z } from "zod";
@Injectable()
export class ZodPipe implements PipeTransform {
constructor(private readonly schema: z.ZodObject<any>) {}
transform(value: any, metadata: ArgumentMetadata) {
this.schema.parse(value);
return value;
}
}