Template
working on words
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user