Repository navigation
Support multiple templates and log sent emails - #7
Merged
Merged
Conversation
db.json now holds { templates, sentEmails }. Each template has its own
tree and its own library of elements; node and element keys are unique
within a template. The old single recipeTemplate is migrated on load
into one template named "Default template" (options become elements).
New: GET/POST /templates, GET/PATCH/DELETE /templates/:templateId.
Tree, elements and generate move under /templates/:templateId; the old
/tree, /elements and /generate routes are removed. Unknown templates
return 404 NOT_FOUND, every change bumps the template's updatedAt, and
generate writes public/generated/<templateId>.html (removed together
with the template).
Breaking change: version 3.0.0.
Sending renders the template and records it in db.json (recipients, subject, template name, HTML snapshot, status "logged"). No email is delivered yet: there is no transport. An empty tree returns 422 TREE_EMPTY; recipients must be 1-50 valid addresses and the subject 1-300 characters. GET /sent-emails lists entries newest first without the HTML; GET /sent-emails/:id returns one entry with it. Entries are kept when their template is deleted.
Ran the store's own migration once: the No More To-Go weekly menu becomes the "Default template" with the same tree and elements.
README: endpoint table under /templates/:templateId, error codes and a v2 to v3 route migration section. AGENTS.md and the add-endpoint skill describe the db.json shape and how template-scoped routes are built.
6 tasks done
Contributor
Author
|
Matching frontend PR: LLazyEmail/email-template-editor-reactjs#63 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Several templates.
db.jsonnow holds{ templates, sentEmails }. Each template has its own tree and its own elements ({ id, name, tree, elements, createdAt, updatedAt }).Automatic migration. An old file with
recipeTemplate: { tree, options }is converted on first start into one template named "Default template". The sampledb.jsonis migrated too.Template CRUD.
GET /templates,POST /templates,GET|PATCH|DELETE /templates/:templateId. Deleting a template also removes its generated file.Tree, elements and generate move under the template:
/templates/:templateId/tree/tree/nodes[/:key]/elements[/:key]/generate/generatewritesgenerated/<templateId>.html, so templates no longer overwrite each other's output.Sent emails log (no delivery yet).
POST /templates/:templateId/send { to, subject }renders the template and records it withstatus: "logged".GET /sent-emailslists entries without the HTML.GET /sent-emails/:idreturns one entry with the HTML snapshot.Validation and errors.
templateIdmust match^[\w-]{1,128}$, because it becomes a file name.NOT_FOUND.Docs and version. OpenAPI, README (endpoints, errors, a v2 → v3 migration section) and AGENTS.md are updated. The version is now 3.0.0.
Breaking:
/tree,/elementsand/generateare removed.Why
The editor supported only one template. This adds several templates, a list of them, and a log of sent emails. There is no SMTP yet: "send" records the email and does not deliver it.
How to verify
npm run lint && npm run format:check && npm run typecheck && npm testall pass (103 tests).npm run openapileaves no diff.db.json.GET /templatesreturned "Default template" with the original tree and 3 elements. Generate and send worked, andGET /treereturned 404.Checklist
npm run lint,npm run typecheck,npm run format:checkpassnpm testpasses; new behavior has a testnpm run openapirun,openapi.jsonand the README endpoint table updated