Skip to content

feat: implement email template preview endpoint - #1366

Merged
davedumto merged 2 commits into
davedumto:mainfrom
johdanike:main
Sep 2, 2026
Merged

feat: implement email template preview endpoint#1366
davedumto merged 2 commits into
davedumto:mainfrom
johdanike:main

Conversation

@johdanike

Copy link
Copy Markdown

🎯 Summary

Implemented the POST endpoint to render email templates with injected sample data to support the preview functionality in routes-b.

📋 Technical Scope & Changes

  • Created handler at app/api/routes-b/email-templates/[id]/preview/route.ts.
  • Integrated authentication checks and enforced template ownership via userId.
  • Added zod validation to parse and enforce structured sampleData payloads.
  • Implemented Handlebars template compilation to return the rendered HTML string.
  • Added comprehensive test coverage in tests/api/routes-b/email-templates/preview.test.ts for:
    • Happy path (200 OK + rendered HTML assertion).
    • Unauthenticated access (401).
    • Missing records (404).
    • Ownership violations (403).

✅ Acceptance Criteria

  • Handler implemented for POST method at the documented path.
  • Validation and error envelopes match existing routes conventions.
  • Unit tests pass in CI. (Pending GitHub Actions run)

Closes #1129

Adds POST handler at /api/routes-b/email-templates/[id]/preview. Includes Zod validation, auth and ownership checks, and Handlebars template compilation. Adds Jest unit testing in the root tests directory covering the happy path and primary failure modes (401, 403, 404).
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@johdanike is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@johdanike Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@davedumto
davedumto merged commit 9fbdc73 into davedumto:main Sep 2, 2026
1 check failed
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.

[routes-b] POST /api/routes-b/email-templates/[id]/preview - render an email template with sample data

2 participants