Skip to content

Commit f290798

Browse files
hubyrodclaude
andcommitted
Update CLAUDE.md with calendar docs, test patterns, and error conventions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c44b5be commit f290798

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,50 @@ GraphQL client with Bearer token auth. `postToSlashwork()` sends formatted markd
6060

6161
### Webhook verification: `src/webhook.ts`
6262

63-
HMAC-SHA256 signature verification using `node:crypto`. Compares `x-hub-signature-256` header against computed hash.
63+
HMAC-SHA256 signature verification using `node:crypto.timingSafeEqual`. Compares `x-hub-signature-256` header against computed hash.
64+
65+
### Calendar integration: `src/calendar/`
66+
67+
Google Calendar polling feature that posts upcoming event reminders to Slashwork streams.
68+
69+
- `auth.ts` — JWT creation + Google OAuth token exchange with 5-minute-buffer caching
70+
- `poller.ts` — Polls calendars at intervals, deduplicates via event keys, hourly cleanup
71+
- `fetch-events.ts` — Google Calendar API v3 calls
72+
- `format.ts` — Markdown formatting with video link extraction, HTML stripping
73+
- `types.ts` — Types matching Google Calendar API response
74+
75+
Calendar config lives in root `config.ts` under `calendar` key. Requires `GOOGLE_SERVICE_ACCOUNT_KEY` env var (full JSON).
76+
77+
## Tests
78+
79+
Test files live next to source: `src/handlers/handlers.test.ts`, `src/webhook.test.ts`, `src/calendar/calendar.test.ts`. Pattern: import `{ test, expect, describe }` from `"bun:test"`.
80+
81+
```sh
82+
bun test # All tests
83+
bun test --filter "handler" # Match test file name
84+
bun test src/calendar/calendar.test.ts # Run single file
85+
```
86+
87+
## Error Response Patterns
88+
89+
- Missing/invalid signature → 401
90+
- Missing headers or unknown event → 200 OK (logged, not forwarded)
91+
- JSON parse failure → 200 OK (logged)
92+
- Request body limit: 1MB (`maxRequestBodySize`)
6493

6594
## Environment Variables
6695

6796
See `.env.example`. Key vars:
6897
- `GITHUB_WEBHOOK_SECRET` — shared secret for webhook signature verification
6998
- `SLASHWORK_GRAPHQL_URL` — GraphQL endpoint
7099
- `SLASHWORK_AUTH_TOKEN_SKIPPER` / `SLASHWORK_AUTH_TOKEN_SKJS` — per-group auth tokens
100+
- `GOOGLE_SERVICE_ACCOUNT_KEY` — service account JSON for calendar feature (optional)
71101
- `PORT` — server port (default 3000)
72102

103+
## TypeScript
104+
105+
Strict mode with `noUncheckedIndexedAccess: true`. Target ESNext with bundler module resolution. Type-check: `bunx tsc --noEmit`.
106+
73107
## Deployment
74108

75-
Clever Cloud via GitHub Actions. Push to `main` → typecheck + tests → auto-deploy.
109+
Clever Cloud via GitHub Actions (`.github/workflows/deploy.yml`). Push to `main` → typecheck + tests → force-push to Clever Cloud repo → auto-deploy.

0 commit comments

Comments
 (0)