Skip to content

feat: implement email template versions endpoints (GET/POST) - #1367

Merged
davedumto merged 2 commits into
davedumto:mainfrom
johdanike:feat/1130-email-template-versions
Sep 2, 2026
Merged

feat: implement email template versions endpoints (GET/POST)#1367
davedumto merged 2 commits into
davedumto:mainfrom
johdanike:feat/1130-email-template-versions

Conversation

@johdanike

Copy link
Copy Markdown

PR Body:
Markdown

🎯 Summary

Implemented the GET and POST endpoints to list and create versions for a specific email template under routes-b.

📋 Technical Scope & Changes

  • Created route handler at app/api/routes-b/email-templates/[id]/versions/route.ts.
  • GET: Retrieves all versions associated with a template ID, ordered by creation date descending.
  • POST: Creates a new version payload. Includes zod validation enforcing subject and content.
  • Integrated PrivyClient (verifyAuthToken) to authenticate the request via Bearer token and enforce template ownership using claims.userId.
  • Added comprehensive test coverage in tests/api/routes-b/email-templates/versions.test.ts checking:
    • Happy paths (200 OK for GET, 201 Created for POST).
    • Validation failures (400).
    • Unauthenticated access (401).
    • Missing records (404).
    • Ownership violations (403).

✅ Acceptance Criteria

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

Closes #1130

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).
Implements listing and creation of template versions. Adds Privy auth checks, Zod validation for new versions, and Prisma integration for data retrieval and storage.
@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 2418b98 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] GET,POST /api/routes-b/email-templates/[id]/versions - list and create email template versions

2 participants