File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 "axios" : " ^1.7.9" ,
1818 "cors" : " ^2.8.5" ,
1919 "dotenv" : " ^16.4.7" ,
20- "express" : " ^4.21.2"
20+ "express" : " ^4.21.2" ,
21+ "zod" : " ^3.24.1"
2122 },
2223 "devDependencies" : {
2324 "@types/cors" : " ^2.8.17" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import cors from 'cors'
33import express from 'express'
44import dotenv from 'dotenv'
55
6+ import * as schema from './schema'
7+
68dotenv . config ( )
79
810const app = express ( )
@@ -12,8 +14,9 @@ app.use(express.json())
1214
1315app . post ( '/' , async ( req , res ) => {
1416 console . log ( `Received POST request:` , req . body )
15- const { url, ...params } = req . body
16- const response = await axios . post ( url , params )
17+ const { url, ...evaluationFunctionRequestData } =
18+ schema . TestServerRequestData . parse ( req . body )
19+ const response = await axios . post ( url , evaluationFunctionRequestData )
1720 res . send ( response . data )
1821} )
1922
Original file line number Diff line number Diff line change 1+ import { z } from 'zod'
2+
3+ export const EvaluationFunctionRequestData = z
4+ . object ( {
5+ answer : z . string ( ) ,
6+ response : z . string ( ) ,
7+ params : z . record ( z . string ( ) , z . any ( ) ) ,
8+ } )
9+ . strict ( )
10+ export type EvaluationFunctionRequestData = z . infer <
11+ typeof EvaluationFunctionRequestData
12+ >
13+
14+ export const TestServerRequestData = EvaluationFunctionRequestData . extend ( {
15+ url : z . string ( ) ,
16+ } ) . strict ( )
17+ export type TestServerRequestData = z . infer < typeof TestServerRequestData >
Original file line number Diff line number Diff line change @@ -1222,3 +1222,8 @@ yocto-queue@^0.1.0:
12221222 version "0.1.0"
12231223 resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
12241224 integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
1225+
1226+ zod@^3.24.1 :
1227+ version "3.24.1"
1228+ resolved "https://registry.yarnpkg.com/zod/-/zod-3.24.1.tgz#27445c912738c8ad1e9de1bea0359fa44d9d35ee"
1229+ integrity sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==
You can’t perform that action at this time.
0 commit comments