feat(api): add global infrastructure modules

This commit is contained in:
dahyeon committed 2026-04-11 03:17:00 +09:00
1 parent 05565f5a44
commit fb59e7721e
15 files changed
+2004

No files matched your search

@@ -0,0 +1,24 @@
import {
ArgumentMetadata,
BadRequestException,
Injectable,
PipeTransform,
} from '@nestjs/common';
import mongoose from 'mongoose';
@Injectable()
export class ParseObjectIdPipe
implements PipeTransform<string, mongoose.Types.ObjectId>
{
public transform(
value: string,
metadata: ArgumentMetadata,
): mongoose.Types.ObjectId {
if (!mongoose.isValidObjectId(value)) {
throw new BadRequestException(
`Invalid ObjectId for ${metadata.data ?? 'param'}.`,
);
}
return new mongoose.Types.ObjectId(value);
}
}