Repository navigation
feat(templates): add Postgres with Drizzle and Dodo Payments templates - #14665
Conversation
Registers three Node function templates from appwrite/templates: - node-typescript/postgres-with-drizzle (appwrite/templates#362), a todo API on Appwrite Postgres through Drizzle ORM. It builds with tsc and runs dist/main.js. - node/payments-with-dodo-payments and node/subscriptions-with-dodo-payments (appwrite/templates#366), which follow the Lemon Squeezy pair. The entries point at templates 1.4.0, the first tag that will contain them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR registers a new Dodo Payments function template in the templates catalog, mirroring the existing Stripe payments template's structure, variables, and store-paid-orders behavior.
Reviewed commit: f732401 |
🔵 Tier A · Mergeable after minor fixes
Adds Postgres with Drizzle and Dodo Payments function templates to the catalog, with their runtime metadata, variables, scopes, and setup instructions. It also restricts the Lemon Squeezy templates to Node 20+ runtimes to match their SDK requirements. Latest changes: The latest commits apply the Node 20+ runtime restriction to both Lemon Squeezy templates by removing Node 18 and 19 from their available runtimes.
Fix with agent prompt### Issue 1
app/config/templates/function.php:364
**Cover the new template mappings in tests**
The existing template-list test checks generic fields, and the deployment test only deploys the starter template, so neither would catch an incorrect source path or build mapping here. Add coverage for the new entries' published runtime metadata or their template deployment setup so these templates cannot appear in the catalog but fail when created.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 1
⏳ Still open from earlier reviews · 1
Reviewed the commits since |
| 'useCases' => [FunctionUseCases::UTILITIES], | ||
| 'runtimes' => [ | ||
| ...getRuntimes( | ||
| $templateRuntimes['NODE'], |
There was a problem hiding this comment.
Exclude Node 18 from the Dodo template runtimes
Both Dodo template packages declare node >=20.0.0, but this runtime list can include node-18.0 (the payments entry does the same). That lets users select an unsupported runtime for these templates; limit both entries to Node 20 or newer.
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/config/templates/function.php
Line: 2294
Comment:
**Exclude Node 18 from the Dodo template runtimes**
Both Dodo template packages declare `node >=20.0.0`, but this runtime list can include `node-18.0` (the payments entry does the same). That lets users select an unsupported runtime for these templates; limit both entries to Node 20 or newer.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · bug · Reply if this doesn't apply.
There was a problem hiding this comment.
Fixed in 1f809b1. The Dodo Payments SDK supports Node 20 and later, so both Dodo entries now drop node-18.0 and node-19.0 from the Node runtimes.
There was a problem hiding this comment.
Adds a payments-with-dodo-payments function template to the catalog, with one scope-set gap flagged against its Stripe sibling.
Key findings
- 🟡 Dodo payments template omits read scopes for orders — function.php:2417
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
| $templateRuntimes['NODE'], | ||
| 'npm install && npm run build', | ||
| 'dist/main.js', | ||
| 'node-typescript/postgres-with-drizzle', |
There was a problem hiding this comment.
Cover the new template mappings in tests
The existing template-list test checks generic fields, and the deployment test only deploys the starter template, so neither would catch an incorrect source path or build mapping here. Add coverage for the new entries' published runtime metadata or their template deployment setup so these templates cannot appear in the catalog but fail when created.
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/config/templates/function.php
Line: 364
Comment:
**Cover the new template mappings in tests**
The existing template-list test checks generic fields, and the deployment test only deploys the starter template, so neither would catch an incorrect source path or build mapping here. Add coverage for the new entries' published runtime metadata or their template deployment setup so these templates cannot appear in the catalog but fail when created.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
There was a problem hiding this comment.
Not adding tests here. Per AGENTS.md, config tests pin what must not disappear and don't mirror config values, so asserting these entries' paths and commands would only repeat the config. Catching a wrong source path or build command means deploying each template, which pulls from GitHub and runs npm install. The payment templates also need Dodo Payments credentials, and automated tests don't call third-party services. Each template will be created from the Console before merging instead.
There was a problem hiding this comment.
@hansi-codes This finding is intentionally not addressed in this PR (see the reply above), so please close it. In short: a test that asserts these entries' paths and commands would only mirror the config, which AGENTS.md rules out for config tests. Catching a wrong mapping means deploying each template from GitHub, and the payment templates would also need Dodo Payments and Lemon Squeezy credentials, which automated tests don't use. Before merging, each new template will be created from the Console instead, as the test plan says.
… for migrations The Dodo Payments SDK supports Node 20 and later, so the two Dodo templates no longer offer node-18.0 and node-19.0. The Postgres with Drizzle instructions now pass DATABASE_URL to npm run db:migrate, which drizzle.config.ts reads, as the template README does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lemonsqueezy/lemonsqueezy.js and both Lemon Squeezy templates require Node 20 or later, so drop node-18.0 and node-19.0 from their runtimes, the same as the Dodo Payments pair. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The previous benchmark run on 3c45c19 showed a regression of about 11–15% (requests/sec −11.5%, P95 +14.9%). It was runner noise: every scenario slowed by a similar amount, including Account and Storage, which never touch templates, and this PR only changes |
What does this PR do?
Adds three Node function templates from
appwrite/templatesto the catalog inapp/config/templates/function.php.postgres-with-drizzlenode-typescript/postgres-with-drizzlenpm install && npm run builddist/main.jssubscriptions-with-dodo-paymentsnode/subscriptions-with-dodo-paymentsnpm installsrc/main.jsusers.read,users.writepayments-with-dodo-paymentsnode/payments-with-dodo-paymentsnpm installsrc/main.jsdatabases.write,tables.read,tables.write,rows.writeDATABASE_URL. The function doesn't create tables, so the instructions say to runnpm run db:migratebefore the first request.DODO_PAYMENTS_API_KEY,DODO_PAYMENTS_WEBHOOK_KEY,DODO_PAYMENTS_PRODUCT_IDand an optionalDODO_PAYMENTS_ENVIRONMENT(defaulttest_mode). Payments also takesAPPWRITE_DATABASE_IDandAPPWRITE_TABLE_ID, both defaulting toorders.getTable,create,createTable,createRow,users.getandupdateLabels.node-18.0andnode-19.0, and this PR applies the same change to the existing Lemon Squeezy pair.query-neon-postgres, and the Dodo pair sits next to Lemon Squeezy. All three use score 6.Templates version
All three entries use
providerVersion1.4.0. That release contains all three templates, and their files are unchanged from the versions reviewed in appwrite/templates#362 and appwrite/templates#366.Test Plan
ConfigandSystem: it returns 44 templates, each new entry has every key the starter has, and the runtimes, commands, entrypoints, root directories, variables and scopes resolve as listed above.php -land Pint (--testwith the repo'spint.json) pass.1.4.0contains all three template directories, and that thepackage.jsonofpostgres-with-drizzlebuilds withtscand setsmaintodist/main.js.Related PRs and Issues
Checklist
🤖 Generated with Claude Code