Skip to content

Commit

Permalink
test response statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii Chernenko committed Jan 27, 2025
1 parent 9acdc7c commit 073dd25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/layers/core/data/server/api/v1/items/index.delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export default defineEventHandler(async (event) => {

await hubKV().set('items', items)

setResponseStatus(event, 204, 'Deleted')
setResponseStatus(event, 200, `Item ${body.data.id} deleted`)

return body.data.id
})
13 changes: 9 additions & 4 deletions src/layers/core/data/server/api/v1/items/index.put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ export default defineEventHandler(async (event) => {
})
}

items.push({
id: crypto.randomUUID(),
const id = crypto.randomUUID()
const item = {
id,
name: `Item ${items.length + 1}`,
})
}

items.push(item)

await hubKV().set('items', items)

setResponseStatus(event, 201, 'Created')
setResponseStatus(event, 201, item)

return item
})

0 comments on commit 073dd25

Please # to comment.