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

overstepping77a97053ebb1
diff --git a/xspace-agent/agent-voice-chat/src/server/middleware/response.js b/xspace-agent/agent-voice-chat/src/server/middleware/response.js
new file mode 100644
index 000000000..b8d71504e
--- /dev/null
+++ b/xspace-agent/agent-voice-chat/src/server/middleware/response.js
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent)
+
+/**
+ * Adds consistent response helpers to res object.
+ *
+ * res.success(data, statusCode?) -> { ok: true, data }
+ * res.fail(code, message, status?, details?) -> { ok: false, error: { code, message, details? } }
+ */
+function responseHelpers(req, res, next) {
+ res.success = (data, statusCode = 200) => {
+ res.status(statusCode).json({ ok: true, data })
+ }
+
+ res.fail = (code, message, status = 400, details) => {
+ const body = { ok: false, error: { code, message, requestId: req.id } }
+ if (details) body.error.details = details
+ res.status(status).json(body)
+ }
+
+ next()
+}
+
+module.exports = { responseHelpers }
+
+