NestJS patterns -- modules, DI, exception filters, validation pipes, guards, interceptors, testing, config
98
89%
Does it follow best practices?
Impact
100%
1.36xAverage score across 12 eval scenarios
Passed
No known issues
A retail startup has a NestJS product catalog API. Their frontend team has complained that error responses from the API come back in inconsistent shapes -- sometimes { statusCode, message }, sometimes a raw stack trace, and sometimes an empty body for unhandled exceptions. This is making it hard to write generic error-handling logic in their React app.
The team wants:
HttpException (like a 404 for a missing product) or from an unexpected runtime error (like a null pointer or DB connection failure). Unknown errors should be logged to the console before the 500 response is sent.Your job is to implement the global exception filter, validation configuration, and product creation endpoint. Write the full main.ts, exception filter, and product module files. A stub service is sufficient.
Produce TypeScript source files in a products-api/src/ directory:
main.ts -- bootstrap with global exception filter and validation pipe configuredcommon/filters/all-exceptions.filter.ts -- the global exception filterapp.module.ts -- root moduleproducts/products.module.ts -- products feature moduleproducts/products.controller.ts -- controller with GET /:id and POST endpointsproducts/products.service.ts -- stub serviceproducts/dto/create-product.dto.ts -- DTO with validation decoratorsDo not run npm install or start the server.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
nestjs-best-practices
verifiers