You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(posts,comments): rate limiting, consistent errors, service unit tests
Closes#999, #1003, #1005, #1007
## What was done
### #1005 — Backend Posts: Add rate limiting on write endpoints
Rate limiting was already wired on PostsController write endpoints (POST,
PUT, DELETE) via @Throttle({ short: { limit: 10, ttl: 60000 } }) and the
global ThrottlerGuard. No change needed there.
### #1003 — Backend Posts/Comments: Return consistent error shape on failure
The global CorrelationExceptionFilter already normalises all unhandled
exceptions into { statusCode, message, correlationId? }. What was missing
was the CommentsController mirroring the same @apiresponse documentation
pattern used in PostsController (explicit 400/404/429/500 schemas with
{ statusCode, message } examples). Updated comments.controller.ts to match.
### #999 — Backend Posts: Add service unit tests for happy path
Extended posts.service.spec.ts create describe block with three additional
happy-path tests:
- 'threads authorId from caller into the created entity'
- 'honours explicit isPublished and isPremium when provided'
- 'returns a mapped PostDto with all expected fields populated'
These complement the existing suite, which already covers findAll,
findByAuthor, findOne, update, softDelete, and PostDeletedEvent.
### #1007 — Backend Comments: Add service unit tests for happy path
Created comments.service.spec.ts from scratch with full happy-path coverage
across all CommentsService methods: create, findAll, findByPost, findOne,
update, and remove. Each describe block tests the success path (correct
arguments forwarded, correct DTO shape returned) and relevant guard rails
(NotFoundException propagation, save not called when entity not found, etc).
## How it was done
- Followed the existing NestJS test patterns (jest mocks via getRepositoryToken,
plainToInstance-mapped DTOs, makeEntity helper factories).
- @Throttle decorator applied at method level on write verbs to match the
posts controller convention; ThrottlerGuard applied at controller level.
- No production logic changed for #999/#1007; only test files were added/extended.
0 commit comments