Skip to content

feat: implement email template version activation endpoint - #1368

Merged
davedumto merged 3 commits into
davedumto:mainfrom
johdanike:feat/1131-activate-email-template-version
Sep 2, 2026
Merged

feat: implement email template version activation endpoint#1368
davedumto merged 3 commits into
davedumto:mainfrom
johdanike:feat/1131-activate-email-template-version

Conversation

@johdanike

Copy link
Copy Markdown

🎯 Summary

Implemented the POST endpoint to activate a specific version of an email template in routes-b.

📋 Technical Scope & Changes

  • Created handler at app/api/routes-b/email-templates/[id]/versions/[v]/activate/route.ts.
  • Integrated verifyAuthToken from Privy to authenticate the user and enforce template ownership.
  • Added validation checks to ensure the requested version exists and is properly linked to the parent template.
  • Implemented the Prisma update logic to set the newly activated version.
  • Added comprehensive unit tests in tests/api/routes-b/email-templates/activate-version.test.ts covering:
    • Happy path (200 OK + database update assertion).
    • Unauthenticated/invalid token requests (401).
    • Parent template or target version not found (404).
    • Mismatched template/version relationship (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)

Closes #1131

johdanike and others added 3 commits August 27, 2026 13:23
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).
Adds POST handler at /api/routes-b/email-templates/[id]/versions/[v]/activate. Secures endpoint with Privy auth verification and enforces template ownership. Adds relational verification to ensure the version belongs to the template before updating the active record. Includes full Jest test coverage for success and all failure states.
@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 47a5dac 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]/versions/[v]/activate - activate an email template version

2 participants