Skip to content

feat(newsroom): add create news – controller, service, validator, routes & tests#62

Merged
DioChuks merged 3 commits intoBuidlZone-Labs:mainfrom
simplicityf:feat/news
Mar 7, 2026
Merged

feat(newsroom): add create news – controller, service, validator, routes & tests#62
DioChuks merged 3 commits intoBuidlZone-Labs:mainfrom
simplicityf:feat/news

Conversation

@simplicityf
Copy link
Contributor

@simplicityf simplicityf commented Mar 1, 2026

Summary

Sets up the newsroom feature slice for creating news articles — validator, service, controller, and route.

Changes

  • validators/news.validator.ts — Zod schema for title, content, category (required) and publishedBy, publishAvatarUrl (optional)
  • services/news.service.tsNewsroomService.createNews() handles validated data, optional image file, and optional imageUrl string, saves to MongoDB via the News model
  • controllers/news.controller.ts — handles POST /news, runs validation, delegates to service, returns 201 on success with structured 400/500 error responses
  • routes/news.routes.ts — mounts POST /news with multer (memory storage, 5 MB cap, images only)
  • tests/news.test.ts — unit tests for NewsService and integration tests for the route

Notes

  • Register the route in app.ts: app.use('/news', newsRoutes)

Testing

# Happy path (works today)
curl -X POST http://localhost:3000/news \
  -H "Content-Type: application/json" \
  -d '{"title":"Test News","content":"<p>Body</p>","category":"Tech","imageUrl":"https://example.com/img.jpg"}'

npx jest newsroom

Related Issue

Closes #55

Screenshots

00

@DioChuks DioChuks self-requested a review March 3, 2026 23:35
Copy link
Contributor

@DioChuks DioChuks left a comment

Choose a reason for hiding this comment

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

Yea, i'm checking in with the blocker PR ❤️

@simplicityf
Copy link
Contributor Author

@DioChuks This has lingered for days, and it is preventing me from working on the second issue at hand

Also, files can be uploaded to storage first (during FE integration), then the file url will be passed to backend. useStorage hook will be setup at the frontend, making it reusable for any endpoints that deals with file upload For example this news endpoint, before sending news form to backend, call the upload function that was setup at useStorage, upload image to the storage, if success pass the file url together with other fields to backend.

There are several projects that follows this process.

To avoid delaying ourselves please.

@DioChuks
Copy link
Contributor

DioChuks commented Mar 6, 2026

@DioChuks This has lingered for days, and it is preventing me from working on the second issue at hand

Also, files can be uploaded to storage first (during FE integration), then the file url will be passed to backend. useStorage hook will be setup at the frontend, making it reusable for any endpoints that deals with file upload For example this news endpoint, before sending news form to backend, call the upload function that was setup at useStorage, upload image to the storage, if success pass the file url together with other fields to backend.

There are several projects that follows this process.

To avoid delaying ourselves please.

yes, i'm quite aware of that, kindly fix your conflicts.

@simplicityf
Copy link
Contributor Author

@DioChuks

@DioChuks DioChuks merged commit e2da697 into BuidlZone-Labs:main Mar 7, 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.

Implement the create newsroom resource

2 participants