Skip to content

Migrate to TypeScript, Netlify Functions v2, and pnpm#28

Open
JoeKarow wants to merge 18 commits intomainfrom
typescript-migration
Open

Migrate to TypeScript, Netlify Functions v2, and pnpm#28
JoeKarow wants to merge 18 commits intomainfrom
typescript-migration

Conversation

@JoeKarow
Copy link
Copy Markdown
Member

@JoeKarow JoeKarow commented Apr 1, 2026

Summary

  • Migrate all JavaScript to TypeScript 6.0.2 with strict mode
  • Update to Netlify Functions v2 (web-standard Request/Response instead of Lambda event/context)
  • Switch from yarn to pnpm
  • Bump Node to v24
  • Update SDKs: @netlify/functions v5, @slack/web-api v7, graphql-request v7, airtable v0.12, luxon v3.7
  • Remove node-fetch (using native fetch) and graphql peer dep
  • Centralize all HMAC/crypto verification in util/verify.ts
  • Add util/env.ts with requireEnv() for runtime env var validation (no non-null assertions)
  • Add env.d.ts for typed process.env
  • Add shared types: types/cms.ts (GraphQL responses), types/room.ts (Airtable room shape)

Netlify Functions v2 changes

  • Scheduled functions use export const config: Config = { schedule } instead of schedule() wrapper
  • HTTP handlers receive Request and return Response
  • HMAC verification uses req.text() for raw body access (critical for signature computation)
  • Background function (-background suffix) convention still works in v2

File renames

All .js.ts renames done via git mv in the first commit to preserve git history.

Test plan

  • pnpm run typecheck passes with zero errors
  • pnpm run build generates data/rooms.json (requires AIRTABLE_COWORKING_BASE)
  • Verify scheduled functions deploy with correct cron schedules
  • Verify Slack event webhook signature verification works end-to-end
  • Verify Zoom webhook signature verification works end-to-end
  • Verify background message dispatch works (slack-send-message-background)

JoeKarow added 17 commits April 1, 2026 18:42
Pure renames with no content changes to preserve git history.
- Migrate from yarn to pnpm
- Add TypeScript 6.0.2 with tsconfig.json
- Update to Node 24
- Update dependencies: @netlify/functions v5, @slack/web-api v7,
  airtable v0.12, graphql-request v7, luxon v3.7
- Remove node-fetch (using native fetch) and graphql peer dep
- Move dotenv to devDependencies
- Add type packages and tsx for build script
- Update netlify.toml for pnpm and v2 functions config
- util/slack.ts: ESM imports, type annotations, drop node-fetch/dotenv
- functions/slack-events/messages.ts: ESM exports, add SlackUser types
- Convert daily, hourly, and weekly reminders to v2 Request/Response
- Replace schedule() wrapper with export const config
- Convert CommonJS to ESM imports
- Add shared CMS GraphQL types in types/cms.ts
- Remove dotenv dependency (Netlify injects env vars)
- slack-events: v2 handler with HMAC verification via req.text()
- slack-interactivity: v2 handler (stub)
- slack-send-message-background: v2 handler for async message dispatch
- Convert CommonJS to ESM, add type annotations
- Convert handler to v2 Request/Response pattern
- Move lazy requires to top-level ESM imports
- Add Room type and Zoom webhook request types
- HMAC verification uses req.text() for raw body
- Airtable helper with proper types
- Convert CommonJS requires to ESM imports
- Replace __dirname with import.meta.url derivation
- Keep dotenv/config for local development
esbuild handles module resolution for Netlify Functions and tsx
handles it for the build script, so nodenext's strict .js extension
requirement is unnecessary.
Add util/env.ts with requireEnv() helper that throws a clear error
if a required environment variable is missing. Applied to all env
vars that were previously using the ! operator.
- verifyHmacSignature: core timing-safe HMAC-SHA256 comparison
- verifySlackRequest: Slack-specific wrapper with timestamp staleness check
- verifyZoomSignature: Zoom-specific wrapper for x-zm-signature header
Add hmacSha256Hex() for Zoom's endpoint URL validation challenge.
Remove node:crypto import from zoom handler — all crypto operations
now go through the shared verify module.
@JoeKarow JoeKarow requested a review from danieltott April 1, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant