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 xspace-agent/xspace-agent/agent-voice-chat/src/server/middleware/validate.js

oversteppingd30444c5d67a
diff --git a/xspace-agent/xspace-agent/agent-voice-chat/src/server/middleware/validate.js b/xspace-agent/xspace-agent/agent-voice-chat/src/server/middleware/validate.js
new file mode 100644
index 000000000..ed59aae7f
--- /dev/null
+++ b/xspace-agent/xspace-agent/agent-voice-chat/src/server/middleware/validate.js
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent)
+
+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 }
+
+