Skip to content

fix(#236,#239): Prisma indexes, soft deletes & multi-NGO RBAC#242

Merged
Cedarich merged 1 commit intoPulsefy:mainfrom
Fahmedo:fix/issues-236-239-rbac-indexes-soft-delete
Mar 30, 2026
Merged

fix(#236,#239): Prisma indexes, soft deletes & multi-NGO RBAC#242
Cedarich merged 1 commit intoPulsefy:mainfrom
Fahmedo:fix/issues-236-239-rbac-indexes-soft-delete

Conversation

@Fahmedo
Copy link
Copy Markdown

@Fahmedo Fahmedo commented Mar 30, 2026

Summary

Fixes #236 and #239 in a single PR.
close #236
close #239

Issue #236 — Prisma Query Optimization & Performance Indexing

  • Added @@index on Claim(status), Claim(campaignId), Claim(createdAt), Claim(deletedAt)
  • Added @@index on Campaign(ngoId), Campaign(deletedAt)
  • Added deletedAt soft-delete column to Campaign and Claim models
  • ClaimsService.findAll/findOne now filter out soft-deleted records
  • CampaignsService.findOne throws NotFoundException for soft-deleted campaigns
  • CampaignsService.softDelete() method added
  • New migration: 20260330000000_rbac_indexes_soft_delete

Issue #239 — Advanced RBAC for Multi-NGO Admin Actions

  • Added ngoId to ApiKey and Campaign Prisma models
  • ApiKeyGuard now attaches ngoId from the DB record to request.user
  • New OrgOwnershipGuard: NGO operators can only access their own org's resources; admins bypass
  • CampaignsController POST/PATCH routes use OrgOwnershipGuard
  • CampaignsService.create() accepts ngoId; findAll() scopes by ngoId for NGO role
  • GET /campaigns is automatically scoped to the caller's ngoId when role is ngo
  • Express.Request type extended with ngoId field

CI

  • Lint: ✅ 0 errors
  • Tests: ✅ 169/169 passed
  • Build: ✅

…-NGO RBAC

Issue Pulsefy#236 - Prisma Query Optimization & Performance Indexing:
- Add @@index on Claim(status), Claim(campaignId), Claim(createdAt), Claim(deletedAt)
- Add @@index on Campaign(ngoId), Campaign(deletedAt)
- Add deletedAt soft-delete column to Campaign and Claim models
- ClaimsService.findAll/findOne now filter out soft-deleted records
- CampaignsService.findOne throws NotFoundException for soft-deleted campaigns
- CampaignsService.softDelete() method added
- New migration: 20260330000000_rbac_indexes_soft_delete

Issue Pulsefy#239 - Advanced RBAC for Multi-NGO Admin Actions:
- Add ngoId to ApiKey and Campaign Prisma models
- ApiKeyGuard attaches ngoId from DB record to request.user
- New OrgOwnershipGuard: NGO operators can only access their org's resources
- CampaignsController: POST/PATCH routes use OrgOwnershipGuard
- CampaignsService.create() accepts ngoId; findAll() scopes by ngoId for NGO role
- GET /campaigns scoped to caller's ngoId when role is ngo
- Express Request type extended with ngoId field

Tests: 169 passed, 0 failed
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@Fahmedo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Cedarich Cedarich merged commit 7b108b9 into Pulsefy:main Mar 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Advanced RBAC for Multi-NGO Admin Actions Prisma Query Optimization & Performance Indexing

2 participants