You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/express-best-practices.md
+16-12Lines changed: 16 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,21 +198,25 @@ router.post(
198
198
199
199
### Reusable cross-cutting middleware
200
200
201
-
Factor recurring concerns (auth, token checks, request logging) into small middleware functions. The token guard is the model to follow:
201
+
Factor recurring concerns (auth, token checks, request logging) into small middleware functions. The token guard is the model to follow — a factory parameterized by the connector credential, so the byte comparison lives in the credential and a route only says which far end it is for (`apps/server/src/middleware/requireCredential.ts`):
202
202
203
203
```ts
204
-
// ✅ GOOD: a focused, reusable guard (apps/server/src/routes/internalMemory.ts)
205
-
functionrequireInternalToken(
206
-
req:Request,
207
-
res:Response,
208
-
next:NextFunction,
209
-
):void {
210
-
if (req.get("authorization") !==`Bearer ${INTERNAL_TOKEN}`) {
211
-
res.status(401).json({ error: "Unauthorized" });
212
-
return;
213
-
}
214
-
next();
204
+
// ✅ GOOD: a focused, reusable guard parameterized by a credential
|`sessions`| one row per session (mirrors the `Session` wire contract, plus `archived`, `user_identity`). |
62
+
|`session_assets`| pinned artifacts, scoped to a session, oldest-first. |
63
+
|`participants`| the roster: session-scoped actor identities (`human` / `agent` / `automation`), capabilities, presence, and each agent's connector facets + `agent_payload`.|
64
+
|`conversations`| per-Conversation `seq` counter and its owning agent; maps a Conversation id to its transcript. |
0 commit comments