feat(incidents): add incident management api (#120)#206
Merged
mijinummi merged 1 commit intoJul 19, 2026
Merged
Conversation
) Implements CRUD, lifecycle status transitions, ownership assignment, severity/priority updates, audit trail, and filtered/paginated/searchable listing for security incidents, per issue MD-Creative-Production#120. Adds first-in-repo RBAC guards (JwtAuthGuard/RolesGuard), a PrismaService-backed repository pattern, class-validator DTOs, and Swagger docs at /api/docs, wired globally via main.ts.
Cybermaxi7
force-pushed
the
feat/120-incident-management-api
branch
from
July 19, 2026 13:54
5fee44d to
41e220f
Compare
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements CRUD, lifecycle status transitions, ownership assignment, severity/priority updates, audit trail, and filtered/paginated/searchable listing for security incidents, per issue #120.
Adds first-in-repo RBAC guards (JwtAuthGuard/RolesGuard), a PrismaService-backed repository pattern, class-validator DTOs, and Swagger docs at /api/docs, wired globally via main.ts.
Type of Change
Related Issues
CLoses #120
Changes Made
IncidentandIncidentAuditLogPrisma models + migration (prisma/schema.prisma,prisma/migrations/20260719120000_add_incidents/)src/modules/incidents/per the issue's suggested structure: controllers, services (IncidentsService,IncidentStatusService,IncidentAssignmentService), repository, DTOs, entities, enums, interfacesnew → open → acknowledged → investigating → contained → resolved → closed, plusreopened); invalid/self transitions rejected with a clear errorIncidentAuditLogentry (actor, action, previous/new values, timestamp) and triggers a notification via the existingNotificationsServiceJwtAuthGuard,RolesGuard,@CurrentUser(),@Roles()(src/common/guards,src/common/decorators)PrismaService/PrismaModule(first repository-pattern usage in the codebase; other modules currently instantiatePrismaClientdirectly)ValidationPipeand Swagger (/api/docs) intomain.tsclass-validator,class-transformer,@nestjs/swagger,@nestjs/jwt,@nestjs/passport,passport,passport-jwt,@nestjs/platform-expressTesting
npm run test)npm run lint)npm run format)npm run build)Also verified against a real local Postgres instance (mirroring CI's
db-migration.yml):prisma migrate deployapplies cleanly on top of the existinginitmigration, andprisma migrate statusreports the schema up to date.47 new unit tests added covering:
IncidentsService(create, findAll, findOne, update, updateSeverity/updatePriority, archive)IncidentStatusService(valid/invalid/self transitions, resolvedAt/closedAt/reopened timestamp handling)IncidentAssignmentService(assign, reassign, remove)IncidentsController(delegation to services, guard overrides)IncidentsRepository(Prisma query shaping, pagination, soft delete, audit writes)class-validatorrules on create/update/status/severity/priority/query DTOs)Run with:
npm run test:backend(ornpx jest --config jest.backend.config.js apps/backend/src/modules/incidents)Checklist
Screenshots (if applicable)
N/A — backend API only. Swagger UI is available at
/api/docsonce the app is running.Additional Context
This is the first module in the repo to use
class-validatorDTOs, Swagger, and real JWT/RBAC guards — existing modules (e.g.cases/notes) use a flatter pattern (interfaces instead of DTOs, no guards, rawPrismaClient). Given issue #120's acceptance criteria explicitly calls for RBAC-ready guards and OpenAPI docs, this PR introduces that shared infrastructure undersrc/common/rather than duplicating ad hoc auth per-endpoint. Happy to discuss whether other modules should migrate to this pattern in a follow-up.