Skip to content

Commit 6f5a61f

Browse files
Update logger refactor plan with Express handler exception
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent e4cae5c commit 6f5a61f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plans/logger-refactor-plan.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ This is a live document. You should update it with any unintutive cases you find
88
- Set `cwd: "backend"` to limit search scope
99
- Exclude websocket-action.ts files
1010

11-
### Step 2: For each file (except websocket-action.ts)
11+
### Step 2: For each file (except websocket-action.ts and index.ts)
1212

1313
- Remove the `import { logger }` line
1414
- Refactor function signature to use single `params` object containing all arguments including `logger: Logger`
1515
- Import proper type: `import type { Logger } from '@codebuff/types/logger'`
1616
- Don't manually type as `{ debug: Function; ... }` - will fail typecheck
1717
- Add destructuring at top of function body to extract params
1818

19+
**Exception: Express Handler Functions**
20+
- Do NOT refactor handler functions that are directly called from Express routes in index.ts (e.g., `usageHandler`, `validateAgentNameHandler`, `getTracesForUserHandler`, `relabelForUserHandler`)
21+
- These handlers should keep their traditional Express signature: `(req, res, next)`
22+
- Instead, wrap them with arrow functions in index.ts that pass logger: `(req, res, next) => handler({ req, res, next, logger })`
23+
- This avoids breaking Express's middleware signature expectations
24+
1925
### Step 3: Update all callers
2026

2127
- **Always run full `bun run typecheck`** (not head/tail!) to find ALL errors

0 commit comments

Comments
 (0)