Skip to content

Commit

Permalink
Don't propagate status messages from internal services
Browse files Browse the repository at this point in the history
  • Loading branch information
junlarsen committed Sep 23, 2024
1 parent bd2939a commit 1e321f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion apps/rif/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function Page() {
const dispatch = useSubmitMutation()
const onSubmit = (data: FormSchema) => {
dispatch.mutate(data)
form.reset()
}

return (
Expand Down
10 changes: 5 additions & 5 deletions apps/rif/src/pages/api/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ export default async function Route(req: NextApiRequest, res: NextApiResponse) {
const json = JSON.parse(req.body)
const parseResult = formSchema.safeParse(json)
if (!parseResult.success) {
console.debug("Failed to parse form with JSON:", json)
return res.status(400)
}
const body = parseResult.data

await createSpreadsheetRow(body)

let response: Response = await deliverConfirmationEmail(body)

if (!response.ok) {
return res.status(response.status).send(await response.text())
console.debug("Failed to dispatch confirmation to sender:", await response.text())
return res.status(500).send({ message: "Failed to dispatch confirmation email" })
}

response = await deliverNotificationEmail(body)
if (!response.ok) {
return res.status(response.status).send(await response.text())
console.debug("Failed to dispatch notifcation to sender:", await response.text())
return res.status(500).send({ message: "Failed to dispatch notification email" })
}

res.status(200).send("OK")
}

0 comments on commit 1e321f9

Please sign in to comment.