Skip to content

Commit

Permalink
send 404 for doc not found when updating doc settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vieiralucas committed Oct 11, 2024
1 parent afc5865 commit 01ea4ea
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Router } from 'express'
import { getParam } from '../../../../../utils/express.js'
import { z } from 'zod'
import { IOServer } from '../../../../../websocket/index.js'
import prisma from '@briefer/database'
import prisma, { recoverFromNotFound } from '@briefer/database'
import { broadcastDocument } from '../../../../../websocket/workspace/documents.js'

const DocumentSettings = z.object({
Expand All @@ -24,11 +24,12 @@ export default function settingsRouter(socketServer: IOServer) {
const runUnexecutedBlocks = body.data.runUnexecutedBlocks

try {
const doc = await prisma().document.update({
where: { id: documentId },
data: { runUnexecutedBlocks },
})

const doc = await recoverFromNotFound(
prisma().document.update({
where: { id: documentId },
data: { runUnexecutedBlocks },
})
)
if (!doc) {
res.status(404).end()
return
Expand Down

0 comments on commit 01ea4ea

Please sign in to comment.