Skip to content

feat(projects): add supporting document upload endpoint (#73)#77

Merged
ayshadogo merged 1 commit into
Dfunder:mainfrom
Uyoxy:feat/project-document-upload
Jun 21, 2026
Merged

feat(projects): add supporting document upload endpoint (#73)#77
ayshadogo merged 1 commit into
Dfunder:mainfrom
Uyoxy:feat/project-document-upload

Conversation

@Uyoxy

@Uyoxy Uyoxy commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements issue #73 — allows project owners to attach supporting documents to their campaign via a new upload endpoint.

Changes

  • src/middlewares/upload.middleware.js — multer config with mimetype filtering, 10MB file size limit, max 5 files, randomized filenames
  • src/models/Project.model.js — added documents[] sub-schema to store file metadata and URLs
  • src/controllers/project.controller.jsuploadDocuments controller with ownership check and total-doc-cap enforcement
  • src/routes/project.routes.js — POST /:id/documents route behind authenticate middleware
  • src/app.js — registered /api/projects routes

Acceptance Criteria

  • POST /api/projects/:id/documents endpoint exists
  • Only the project owner can upload (403 for others)
  • Accepted types: PDF, DOCX, JPG, PNG — others are rejected with 400
  • Max 10MB per file enforced
  • Max 5 documents per project (across all uploads, not just one request)
  • File references appended to project.documents[]

Testing

  • Upload 1–5 valid files as owner → 201 with document list
  • Upload as non-owner → 403
  • Upload unsupported type (e.g. .csv) → 400
  • Upload file > 10MB → 400
  • Upload files that would push total past 5 → 400 with remaining slots message
    closes Upload Project Supporting Documents #73

- Add POST /api/projects/:id/documents route
- Restrict uploads to project owners via ownership check
- Accept PDF, DOCX, JPG, PNG only (validated by mimetype)
- Enforce 10MB per-file limit and max 5 files per project
- Store file references in project.documents[] array
- Add upload.middleware.js using multer with disk storage
- Serve uploaded files via existing /uploads static middleware

@ayshadogo ayshadogo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you for your contribution 🤝

@ayshadogo ayshadogo merged commit cc868e4 into Dfunder:main Jun 21, 2026
1 check passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 21, 2026
4 tasks
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.

Upload Project Supporting Documents

2 participants