# Connect Postgres for Hono

## Summary
Database connection for a Hono app on Ample. Verified on Hono: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok). Build and start: npm install and npm run start with @hono/node-server on the node-22 template.

## Representative Queries
- Connect Postgres for Hono
- Where can I host Connect Postgres built with Hono?
- I need driver setup, connection settings, secret handling and a real connection test.

## Resource Requirements
- primitive:compute
- primitive:postgres

## Infrastructure Requirements
- **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- **Postgres**: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.

## Prerequisites
- A Hono project (npm install and npm run start with @hono/node-server on the node-22 template)
- A PostgreSQL driver reading DATABASE_URL at runtime
- An Ample account token with servers:write, databases:read

## Workflow Steps
1. **Build and start**: npm install and npm run start with @hono/node-server on the node-22 template; the server must bind 0.0.0.0 on PORT.
2. **Read DATABASE_URL at runtime**: Open connections from the environment inside handlers or a pool; omit DATABASE_URL to auto-provision a managed database or pass --env DATABASE_URL=... for an existing one.
3. **Verify**: Fetch the live URL and /p/relational-records on the example; on failure read the build and runtime logs.

## Examples
- **Hono pattern fixture**: Verified database connection on Hono.
  - Source Reference: tests/deploy-canaries/hono-patterns

## Success Checks
- app responds on its public URL
- relational-records check from the example

## Limitations
- Verified on the node-22 template at s-1vcpu-1gb; other sizes and Hono major versions are not verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- Managed PostgreSQL 16 only; extensions, connection limits and backup or restore procedures are not verified.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Basis**: size prices from pricing.toml at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty.
  - Components:
    - **App server**: s-1vcpu-1gb, quantity: 1.0, monthlyAmount: 5.0
    - **Managed PostgreSQL database**: s-1vcpu-1gb, quantity: 1.0, monthlyAmount: 5.0
- Note: Always-on monthly price of the tested sizes; apps auto-pause when idle.

## Evidence Summary
- **Kind**: canary_run
- **Summary**: Hono pattern fixture deployed on Ample; a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time.
  - Observed At: 2026-09-21T01:14:18Z
  - Expires At: 2027-03-20T01:14:18Z

## Next Actions
- **Browse the catalog index**: /v1/catalog
- **Search published recipes by intent, stack and constraints**: /v1/catalog/search
- **Prepare a side-effect-free deployment plan for an authorized project**: /v1/catalog/plan
- **Read the existing agent authentication setup**: /mcp/setup
- **Browse Hono**: /v1/catalog/nodes/stack%3Aframework-hono
- **Browse Connect app to database**: /v1/catalog/nodes/intent%3Aconnect-app-to-database
- **Browse Relational records**: /v1/catalog/nodes/pattern%3Arelational-records
