CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/nestjs-best-practices

NestJS patterns -- modules, DI, exception filters, validation pipes, guards, interceptors, testing, config

98

1.36x
Quality

89%

Does it follow best practices?

Impact

100%

1.36x

Average score across 12 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

Notifications Service Refactor

Problem/Feature Description

A food delivery platform has an existing NestJS backend where a NotificationsController directly instantiates SMS and email clients using new SmsClient() and new EmailClient() inside the controller methods. The backend team has flagged this as a problem: it's impossible to test the controller in isolation, and any business logic changes require touching HTTP-level code. They also noticed that the controller is performing validation logic, price calculations, and message formatting — none of which belong there.

You have been asked to refactor the notifications feature into a proper NestJS architecture. There should be a NotificationsService that handles all business logic (composing messages, choosing SMS vs email based on user preference, etc.) and a lean controller that only deals with HTTP concerns. The service should depend on separate SmsService and EmailService providers that are themselves injectable. None of these services should reach into the HTTP request/response layer.

Write the refactored notifications module from scratch. You can use in-memory stubs for SmsService and EmailService — no real external clients are needed.

Output Specification

Produce TypeScript source files in notifications-api/src/:

  • notifications/notifications.module.ts
  • notifications/notifications.controller.ts
  • notifications/notifications.service.ts
  • notifications/sms.service.ts
  • notifications/email.service.ts
  • notifications/dto/send-notification.dto.ts

Include a brief README.md describing how the dependency injection is wired up.

evals

scenario-1

criteria.json

task.md

tile.json