Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

add agent-voice-chat/src/server/middleware/validate.js

overstepping55f45bd819e2
diff --git a/agent-voice-chat/src/server/middleware/validate.js b/agent-voice-chat/src/server/middleware/validate.js
new file mode 100644
index 000000000..6a05c4875
--- /dev/null
+++ b/agent-voice-chat/src/server/middleware/validate.js
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/agent-voice-chat)
+
+const { ZodError } = require("zod")
+
+function validate(schema) {
+ return (req, res, next) => {
+ try {
+ req.body = schema.parse(req.body)
+ next()
+ } catch (err) {
+ if (err instanceof ZodError) {
+ return res.fail(
+ "VALIDATION_ERROR",
+ "Request body validation failed",
+ 400,
+ err.issues.map(e => ({ path: e.path.join("."), message: e.message }))
+ )
+ }
+ next(err)
+ }
+ }
+}
+
+module.exports = { validate }