Edge Function Architect
This skill enforces the "Mirrored Logic" pattern required by this project's unique Deno/Node hybrid architecture.
The Problem
Supabase Edge Functions run on Deno, but our test suite runs on Node.js (Vitest). This makes sharing code (like validation logic and types) difficult without a complex build step.
The Solution: Mirrored Logic
We explicitly duplicate the core validation logic in the test file. This ensures that even though the runtimes are different, the business rules are verified locally before deployment.
Usage
Scaffold a New Function
This command creates both the Deno Edge Function and its corresponding "Mirrored Logic" test file.
bash
node .gemini/skills/edge-function-architect/scripts/scaffold_edge_function.cjs <function-name>
Example
To create a new function called process-receipts:
bash
node .gemini/skills/edge-function-architect/scripts/scaffold_edge_function.cjs process-receipts
Output:
- •
supabase/functions/process-receipts/index.ts(The Deno backend) - •
test/process-receipts-logic.test.ts(The Vitest mirror)
Workflow
- •Scaffold: Run the command above.
- •Verify: Run
pnpm testimmediately to ensure the boilerplate passes. - •Implement:
- •Add your business logic to the
index.tsfile. - •Crucial: Copy any validation rules or schema checks into the
testfile'svalidateInputmock. - •Update tests to cover the new logic.
- •Add your business logic to the