Skip to content

feat(templates): add Postgres with Drizzle and Dodo Payments templates - #14665

Merged
adityaoberai merged 3 commits into
mainfrom
feat/function-templates-drizzle-dodo-payments
Oct 19, 2026
Merged

adityaoberai merged 3 commits into
mainfrom
feat/function-templates-drizzle-dodo-payments

Conversation

@adityaoberai

@adityaoberai adityaoberai commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds three Node function templates from appwrite/templates to the catalog in app/config/templates/function.php.

ID Source Use case Build Entrypoint Scopes
postgres-with-drizzle node-typescript/postgres-with-drizzle Databases npm install && npm run build dist/main.js none
subscriptions-with-dodo-payments node/subscriptions-with-dodo-payments Utilities npm install src/main.js users.read, users.write
payments-with-dodo-payments node/payments-with-dodo-payments Utilities npm install src/main.js databases.write, tables.read, tables.write, rows.write
  • Postgres with Drizzle serves a todo API on Appwrite Postgres through Drizzle ORM. Its only variable is DATABASE_URL. The function doesn't create tables, so the instructions say to run npm run db:migrate before the first request.
  • Dodo Payments follows the Lemon Squeezy pair. Both templates take DODO_PAYMENTS_API_KEY, DODO_PAYMENTS_WEBHOOK_KEY, DODO_PAYMENTS_PRODUCT_ID and an optional DODO_PAYMENTS_ENVIRONMENT (default test_mode). Payments also takes APPWRITE_DATABASE_ID and APPWRITE_TABLE_ID, both defaulting to orders.
  • Variables, scopes, build commands and entrypoints come from each template's README and source. I checked the scopes against the endpoints the templates call: getTable, create, createTable, createRow, users.get and updateLabels.
  • The Dodo Payments SDK and the Lemon Squeezy SDK both require Node 20 or later. The two Dodo entries leave out node-18.0 and node-19.0, and this PR applies the same change to the existing Lemon Squeezy pair.
  • The Drizzle entry sits next to query-neon-postgres, and the Dodo pair sits next to Lemon Squeezy. All three use score 6.

Templates version

All three entries use providerVersion 1.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

  • Loaded the config with stubbed Config and System: 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 -l and Pint (--test with the repo's pint.json) pass.
  • Checked that 1.4.0 contains all three template directories, and that the package.json of postgres-with-drizzle builds with tsc and sets main to dist/main.js.
  • Still to do: create each template from the Console and confirm the deployment builds.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? Not applicable: no API metadata changed.

🤖 Generated with Claude Code

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]>
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@adityaoberai
adityaoberai marked this pull request as ready for review October 19, 2026 12:59
@luxor-code-review

luxor-code-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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.

Files Change
app/config/templates/function.php Adds the payments-with-dodo-payments template entry with runtime metadata, provider references, required variables (API key, webhook secret, mode), and a grants scope set for its webhook handler.

Reviewed commit: f732401

@ghost

ghost commented Oct 19, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The previously reported gap in test coverage for the new template mappings remains open.

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.

Verdict New comments Fixed Still open
✅ Approved 0 0 1
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
File Change
app/config/templates/function.php Adds the Drizzle and Dodo Payments templates and adjusts the available runtimes for Dodo and Lemon Squeezy templates.
⏳ Still open from earlier reviews · 1

Reviewed the commits since 1f809b1 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

Comment thread app/config/templates/function.php Outdated
'useCases' => [FunctionUseCases::UTILITIES],
'runtimes' => [
...getRuntimes(
$templateRuntimes['NODE'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a payments-with-dodo-payments function template to the catalog, with one scope-set gap flagged against its Stripe sibling.

Key findings

Comment thread app/config/templates/function.php Resolved
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/function-templates-drizzle-dodo-payments (after).

Metric Before After Change
🚀 Requests/sec 201.63 198.13 ⚪ -1.7%
⏱️ Latency P50 85.51 ms 87.82 ms ⚪ +2.7%
⏱️ Latency P95 194.41 ms 202.23 ms ⚪ +4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 87.82 202.23 12,540 198.13 +7.82
Account 160.48 297.31 660 11.22 +14.72
TablesDB 84.41 151.8 6,820 111.03 -10.01
Storage 83.15 196 3,300 55.09 +3.86
Functions 125.53 233.85 1,760 29.97 +14.06

Top API waits (after)

API request Max wait (ms)
functions.create 496.06
account.name.update 428.48
account.prefs.update 405.25
storage.buckets.create 372.29
storage.files.create 370.69

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

Comment thread app/config/templates/function.php Resolved
$templateRuntimes['NODE'],
'npm install && npm run build',
'dist/main.js',
'node-typescript/postgres-with-drizzle',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

adityaoberai and others added 2 commits October 19, 2026 18:39
… 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]>
@adityaoberai

Copy link
Copy Markdown
Contributor Author

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 app/config/templates/function.php. A re-run of the benchmark job on the same commit came back within normal variance (requests/sec −1.7%, P95 +4%), and the benchmark comment above now shows those numbers.

@adityaoberai
adityaoberai merged commit 199888b into main Oct 19, 2026
122 checks passed
@adityaoberai
adityaoberai deleted the feat/function-templates-drizzle-dodo-payments branch October 19, 2026 19:05
@ChiragAgg5k ChiragAgg5k mentioned this pull request Oct 21, 2026
6 tasks
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.

1 participant