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/request-id.js

oversteppingde2509b38626
diff --git a/agent-voice-chat/src/server/middleware/request-id.js b/agent-voice-chat/src/server/middleware/request-id.js
new file mode 100644
index 000000000..311e68e53
--- /dev/null
+++ b/agent-voice-chat/src/server/middleware/request-id.js
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/agent-voice-chat)
+
+const { randomUUID } = require("crypto")
+
+/**
+ * Middleware: assign a unique request ID to every HTTP request.
+ * - Respects an incoming X-Request-Id header (for proxy/tracing chains).
+ * - Echoes the ID back in the X-Request-Id response header.
+ * - Exposes it as req.id so all downstream handlers and loggers can use it.
+ */
+function requestId(req, res, next) {
+ req.id = req.headers["x-request-id"] || randomUUID()
+ res.setHeader("X-Request-Id", req.id)
+ next()
+}
+
+module.exports = { requestId }