feat(newsroom): add create news – controller, service, validator, routes & tests#62
Conversation
DioChuks
left a comment
There was a problem hiding this comment.
Yea, i'm checking in with the blocker PR ❤️
|
@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. |
Summary
Sets up the newsroom feature slice for creating news articles — validator, service, controller, and route.
Changes
validators/news.validator.ts— Zod schema fortitle,content,category(required) andpublishedBy,publishAvatarUrl(optional)services/news.service.ts—NewsroomService.createNews()handles validated data, optional image file, and optionalimageUrlstring, saves to MongoDB via theNewsmodelcontrollers/news.controller.ts— handlesPOST /news, runs validation, delegates to service, returns201on success with structured400/500error responsesroutes/news.routes.ts— mountsPOST /newswith multer (memory storage, 5 MB cap, images only)tests/news.test.ts— unit tests forNewsServiceand integration tests for the routeNotes
app.ts:app.use('/news', newsRoutes)Testing
Related Issue
Closes #55
Screenshots