feat(deno): Add Deno + Aurora DSQL samples with booking API#950
Closed
pyraenix wants to merge 1 commit into
Closed
feat(deno): Add Deno + Aurora DSQL samples with booking API#950pyraenix wants to merge 1 commit into
pyraenix wants to merge 1 commit into
Conversation
Add Deno runtime samples for connecting to Amazon Aurora DSQL, including a basic client/ORM sample and a real-world booking API sample application. Deno is the first new runtime added to this repository that uses a native (non-Node.js) PostgreSQL driver. ## deno/deno-postgres — Basic Client/ORM Sample Simple connect-and-query example using the native deno-postgres driver (jsr:@db/postgres) with IAM token authentication over SSL verify-full. Demonstrates concurrent queries across multiple connections. Follows the same pattern as javascript/node-postgres. - src/example_preferred.ts — main example - test/example_preferred.test.ts — integration test - deno.json, deno.lock, README.md, .gitignore ## deno/booking-api/deno-postgres — Booking API Sample Application A booking/reservation REST API built with Deno.serve() and deno-postgres, backed by Aurora DSQL. Goes beyond connect-and-query to demonstrate real application patterns: - Full CRUD: POST/GET/PUT/DELETE /bookings + GET /health - IAM token authentication via @aws-sdk/dsql-signer - OCC retry handling for SQLSTATE OC000 concurrency conflicts with exponential backoff + jitter - Overlap detection for double-booking prevention within transactions (DSQL has no exclusion constraints) - Deno least-privilege permissions model (--allow-net, --allow-env, --allow-read scoped to minimum required) - Serverless-ready architecture (deno serve compatible, per-request connections, no mutable global state) - UUID primary keys via gen_random_uuid() (DSQL has no sequences) - Graceful shutdown with schema teardown on SIGINT/SIGTERM ### Testing (all verified against real Aurora DSQL cluster) - 20 property-based tests (fast-check): router dispatch, overlap detection symmetry, JSON response format, malformed JSON rejection, OCC error detection/retry/exhaustion/pass-through, token generator error formatting - 9 integration tests: full CRUD flow against real DSQL - 15 smoke tests (test-api.sh): health check, CRUD, overlap conflict, concurrent OCC conflict, validation errors, cleanup ### Documentation - Architecture diagram (ASCII art) - Create booking request flow diagram - Data model diagram - Key design decisions table for Aurora DSQL - API endpoints table with status codes - Error response examples - Deno permissions model explanation - OCC retry behavior section - Deno Deploy deployment instructions - Example curl commands for all endpoints - Project structure overview ## Root README Updated the repository root README.md to include Deno in the Client/ORM table and the booking API in the Sample Applications table. ## Technical Notes - npm:pg (node-postgres) was evaluated but does not work with Aurora DSQL from Deno due to a TLS compatibility issue in Deno's Node.js compat layer. Only the native deno-postgres driver is included. - Authentication and cluster management samples are intentionally omitted — they are pure AWS SDK calls with no Deno-specific value, matching the pattern of TypeScript and PHP samples.
This was referenced May 1, 2026
gxjx-x
added a commit
that referenced
this pull request
May 6, 2026
## Summary Adds Deno runtime samples for Amazon Aurora DSQL — a basic client example and a full booking-API sample application. Both samples use the official [`@aws/aurora-dsql-postgresjs-connector`](https://github.com/awslabs/aurora-dsql-connectors/tree/main/node/postgres-js), which handles IAM token generation and refresh, SSL/TLS, pooling, and region auto-discovery. ## What's included ### `deno/postgres-js/` — Basic client sample Connect-and-query example using `@aws/aurora-dsql-postgresjs-connector` over IAM-authenticated TLS. Demonstrates concurrent queries across a pooled client. Follows the layout used by `javascript/postgres-js/`. - `src/example_preferred.ts` — main example - `test/example_preferred.test.ts` — integration test - `deno.json`, `deno.lock`, `README.md`, `LICENSE` ### `deno/booking-api/postgres-js/` — Booking API sample A booking/reservation REST API built with `Deno.serve()` and the postgres.js connector, backed by Aurora DSQL. Beyond connect-and-query, this sample shows real application patterns: - Full CRUD over `/bookings` plus a `GET /health` endpoint - Layered defense against double-booking: in-transaction overlap check, a `UNIQUE` async index on `(resource_name, start_time, end_time)` as a commit-time backstop, and automatic retry on OCC conflicts (SQLSTATE `40001`) - Pooled IAM-authenticated connections; the connector refreshes tokens transparently - Request hardening: 16 KB JSON body cap, strict UUID v4 path regex, redacted error logging - Safe-by-default bind to `127.0.0.1` (override via `HOST`) with a production note on reverse-proxy deployment - Graceful HTTP shutdown: drains in-flight requests before closing the pool on `SIGINT`/`SIGTERM` - UUID primary keys via `gen_random_uuid()` — see the [Aurora DSQL guide on sequences and identity columns](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/sequences-identity-columns.html) if you prefer compact integer keys - Application-layer referential integrity, as recommended by the [Aurora DSQL migration guide](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-postgresql-compatibility-migration-guide.html) ### `deno/CONTRIBUTORS.md` Credits original and follow-up authors. ### CI workflows Adds `deno-postgresjs-integ-tests.yml` and `deno-booking-api-integ-tests.yml` mirroring the existing `javascript-postgresjs` pattern. Both workflows run Deno integration tests against a fresh DSQL cluster (created and torn down per run), and both are wired into `ci-gate.yml`. For now they piggy-back on `secrets.JAVASCRIPT_IAM_ROLE` rather than introducing a separate `DENO_IAM_ROLE` — a maintainer can move them to a dedicated role in a follow-up if needed. ## Testing All tests verified against a live Aurora DSQL cluster: - **18 unit + property tests + 13 integration tests** (`fast-check`, `@std/assert`): router dispatch, overlap symmetry, JSON response format, malformed-input rejection, OCC retry/exhaustion/pass-through, concurrent overlap-race behavior, scoped test cleanup - **14 smoke tests** (`test-api.sh`): health check, CRUD lifecycle, overlap conflict, concurrent OCC, validation errors ## Documentation The booking-API README covers architecture, request flow, data model, Aurora DSQL design decisions, API endpoints with status codes, error response shapes, the Deno permissions model, OCC retry behavior, optional Deno Deploy deployment, and example `curl` commands. Production guidance calls out keyset pagination for `GET /bookings` and running CRUD as a non-admin database role — see the [Aurora DSQL guide on database roles and IAM authentication](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/using-database-and-iam-roles.html). ## Notes for reviewers - The repository root `README.md` is updated to list the two Deno samples alongside existing entries in the Client/ORM and Sample Applications tables - Authentication and cluster-management samples are intentionally omitted — these would be AWS SDK calls with no Deno-specific value, matching the conventions already used for TypeScript and PHP - Commit history is intentionally granular (one commit per theme) to ease review ## Credits Builds on [#950](#950) by [@pyraenix](https://github.com/pyraenix), credited as co-author on every commit. Some commits in this PR were authored with assistance from [Kiro](https://kiro.dev). --- By submitting this pull request, I confirm that my contribution is made under the terms of the MIT-0 license. --------- Co-authored-by: premarixx <iverixpyraen@gmail.com>
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.
Add Deno runtime samples for connecting to Amazon Aurora DSQL, including a basic client/ORM sample and a real-world booking API sample application. Deno is the first new runtime added to this repository that uses a native (non-Node.js) PostgreSQL driver.
deno/deno-postgres — Basic Client/ORM Sample
Simple connect-and-query example using the native deno-postgres driver (jsr:@db/postgres) with IAM token authentication over SSL verify-full. Demonstrates concurrent queries across multiple connections. Follows the same pattern as javascript/node-postgres.
deno/booking-api/deno-postgres — Booking API Sample Application
A booking/reservation REST API built with Deno.serve() and deno-postgres, backed by Aurora DSQL. Goes beyond connect-and-query to demonstrate real application patterns:
Testing (all verified against real Aurora DSQL cluster)
Documentation
Root README
Updated the repository root README.md to include Deno in the Client/ORM table and the booking API in the Sample Applications table.
Technical Notes
By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT-0 license.
Thank you for your contribution!