File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 11import { vendoJourneySchema } from "@/utils/schemas" ;
22import { createClient } from "db-vendo-client" ;
33import { profile as dbProfile } from "db-vendo-client/p/db/index" ;
4- import { z } from "zod/v4" ;
4+ import { prettifyError , z } from "zod/v4" ;
55import {
66 getApiCount ,
77 incrementApiCount ,
@@ -53,11 +53,25 @@ const handler = async (request: Request) => {
5353 // Verbindungen von DB-API abrufen
5454 const journeys = await client . journeys ( urlParams . from , urlParams . to , options ) ;
5555
56- const parsed = z
56+ const parseResult = z
5757 . object ( { journeys : z . array ( vendoJourneySchema ) } )
58- . parse ( journeys ) ;
58+ . safeParse ( journeys ) ;
5959
60- let allJourneys = parsed . journeys ;
60+ if ( ! parseResult . success ) {
61+ return Response . json (
62+ {
63+ success : false ,
64+ error : `Validation of 'journeys' on DB-API failed: ${ prettifyError (
65+ parseResult . error
66+ ) } `,
67+ } ,
68+ {
69+ status : 500 ,
70+ }
71+ ) ;
72+ }
73+
74+ let allJourneys = parseResult . data . journeys ;
6175
6276 console . log ( `Received ${ allJourneys . length } journeys from main query` ) ;
6377
You can’t perform that action at this time.
0 commit comments