Add Zod validation to all API endpoints and remove debug test route
Adds schema-based input validation across helcim, events, members, series, admin, and updates API endpoints. Removes the peer-support debug test endpoint. Adds validation test coverage.
This commit is contained in:
parent
e4813075b7
commit
025c1a180f
38 changed files with 1132 additions and 309 deletions
|
|
@ -7,15 +7,7 @@ export default defineEventHandler(async (event) => {
|
|||
const admin = await requireAdmin(event)
|
||||
await connectDB()
|
||||
|
||||
const body = await readBody(event)
|
||||
|
||||
// Validate required fields
|
||||
if (!body.id || !body.title || !body.description) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'Series ID, title, and description are required'
|
||||
})
|
||||
}
|
||||
const body = await validateBody(event, adminSeriesCreateSchema)
|
||||
|
||||
// Create new series
|
||||
const newSeries = new Series({
|
||||
|
|
@ -43,9 +35,10 @@ export default defineEventHandler(async (event) => {
|
|||
})
|
||||
}
|
||||
|
||||
if (error.statusCode) throw error
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: error.message || 'Failed to create series'
|
||||
statusMessage: 'An unexpected error occurred'
|
||||
})
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue