Mid
18 listopada 2026

Znajdź błąd: Node.js / NestJS

Jeden fragment kodu. Znajdź błąd albo udowodnij, że go nie ma.

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}

Kliknij linie, które powodują problem.

Twój werdykt

Jedna próba dziennie. Odpowiedź pojawi się od razu potem.

Zachowaj swoją serię

Załóż konto, aby zachować serię i śledzić postępy.

Załóż konto