working on words

This commit is contained in:
2024-12-29 12:04:19 +01:00
parent de8b4c5000
commit 933fe2635b
19 changed files with 182 additions and 46 deletions
+20
View File
@@ -0,0 +1,20 @@
import {
HttpException,
HttpStatus,
Injectable,
PipeTransform,
} from '@nestjs/common';
import { WordService } from '../services/word.service';
@Injectable()
export class WordPipe implements PipeTransform {
constructor(private readonly wordService: WordService) {}
async transform(id: number) {
const word = await this.wordService.getById(id);
if (!word) {
throw new HttpException('Word not found', HttpStatus.NOT_FOUND);
}
return word;
}
}