Difficulty: Intermediate
Context
Server and channel mutation routes in server/routes/servers.js accept several request body fields and MongoDB IDs. Some paths can fail with generic server errors when required fields are missing or malformed.
Improving validation will make the API easier to use, safer for contributors, and more predictable for the frontend.
Expected work
- Validate required fields for creating servers, categories, and channels.
- Validate MongoDB ObjectId values before constructing
mongoose.Types.ObjectId.
- Return consistent
400 responses for malformed input.
- Return useful
404 responses when a referenced server/category does not exist.
- Keep existing successful response shapes compatible with the frontend.
Acceptance criteria
- Missing
server_id, category_id, channel_name, or category_name returns a clear 400.
- Invalid MongoDB IDs do not throw uncaught errors.
- Failed updates return appropriate status codes instead of generic success-shaped responses.
- Existing create server/category/channel flows still work.
- Manual API testing or backend tests cover at least one valid and one invalid case.
Suggested files
server/routes/servers.js
server/services/serverService.js
Difficulty: Intermediate
Context
Server and channel mutation routes in
server/routes/servers.jsaccept several request body fields and MongoDB IDs. Some paths can fail with generic server errors when required fields are missing or malformed.Improving validation will make the API easier to use, safer for contributors, and more predictable for the frontend.
Expected work
mongoose.Types.ObjectId.400responses for malformed input.404responses when a referenced server/category does not exist.Acceptance criteria
server_id,category_id,channel_name, orcategory_namereturns a clear400.Suggested files
server/routes/servers.jsserver/services/serverService.js