ミドル
2026年11月18日

バグを見つけろ:Node.js / NestJS

コードは1つ。バグを見つけるか、バグがないことを示してください。

typescript
1@Injectable()
2export class ArticleService {
3  constructor(
4    private redis: Redis,
5    private prisma: PrismaService,
6  ) {}
7
8  async getArticleById(id: string): Promise<Article | null> {
9    const cacheKey = `article:${id}`;
10    const cached = await this.redis.get(cacheKey);
11    if (cached) return JSON.parse(cached);
12    const article = await this.prisma.article.findUnique({ where: { id } });
13    if (!article) return null;
14    await this.redis.set(cacheKey, JSON.stringify(article), 'EX', 600);
15    return article;
16  }
17}

問題のある行をクリックしてください。

あなたの判断

1日1回まで。回答するとすぐに正解が表示されます。

連続記録を守る

アカウントを作成すると連続記録を保存し、進捗を追跡できます。

アカウントを作成