# Configure S3-compatible access for NestJS

## Summary
Object storage client for a NestJS app on Ample. Verified on NestJS: bucket credentials delivered as encrypted S3_* environment variables and a validated PutObject/GetObject round-trip linked to a database row (upload=ok linked=ok). Build and start: `npm install`, `nest build` (TypeScript) then `node dist/main.js` on the node-22 template.

## Prerequisites
- A NestJS project (`npm install`, `nest build` (TypeScript) then `node dist/main.js` on the node-22 template)
- A bucket from `ample bucket create` with credentials passed as encrypted S3_* environment variables
- An Ample account token with `servers:write`, `buckets:read`

## Resource Requirements
- **Primitive:** Compute
- **Primitive:** S3-compatible object storage

## Workflow Steps
1. **Build and start**  
   `npm install`, `nest build` (TypeScript) then `node dist/main.js` on the node-22 template; the server must bind 0.0.0.0 on PORT.

2. **Create the bucket and pass its credentials**  
   Create it once with `ample bucket create`, then pass endpoint, region, bucket and keys with --env; use path-style addressing.  
   Command: `ample deploy . --name  --public --env S3_ENDPOINT=... --env S3_REGION=... --env S3_BUCKET=... --env S3_ACCESS_KEY_ID=... --env S3_SECRET_ACCESS_KEY=...`

3. **Verify**  
   Fetch the live URL and `/p/browser-file-uploads` on the example; on failure read the build and runtime logs.  
   Command: `ample logs  --kind build`

## Examples
### NestJS pattern fixture  
Verified object storage client on NestJS.  
Source Reference: `tests/deploy-canaries/nestjs-patterns`

## Success Checks
- App responds on its public URL
  - Kind: `http_get`  
  - Path: `/`  
  - Expect: `ample canary nestjs patterns`
- Browser-file-uploads check from the example
  - Kind: `http_get`  
  - Path: `/p/browser-file-uploads`  
  - Expect: `see the pattern fixture checks`

## Limitations
- Verified on the node-22 template at s-1vcpu-1gb; other sizes and NestJS major versions are not verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- PutObject and GetObject with path-style addressing are verified; other S3 operations are not.

## Cost Estimate
- **Currency:** USD  
- **Monthly Amount:** 5.0  
- **Basis:** size prices from pricing.toml (loaded by the API) at build revision `1ac5595375130d45290090e82ed0f554ccd45405-dirty`  
- **Components:**  
  - Name: `app server`, Size: `s-1vcpu-1gb`, Quantity: 1.0, Monthly Amount: 5.0  
- **Note:** Always-on monthly price of the tested sizes; apps auto-pause when idle. Buckets are allocation-priced per quota and not included.

## Evidence Summary
- **Kind:** canary_run  
- **Summary:** NestJS pattern fixture deployed on Ample (`npm install`, `nest build` (TypeScript) then `node dist/main.js` on the node-22 template); for this guide: bucket credentials delivered as encrypted S3_* environment variables and a validated PutObject/GetObject round-trip linked to a database row (upload=ok linked=ok).  
- **Observed At:** 2026-09-21T02:34:39Z  
- **Implementation Revision:** 1d28ae0-dirty (CLI 0.1.21)  
- **Expires At:** 2027-03-20T02:34:39Z  
- **Scope:**  
  - Checks: `/p/browser-file-uploads`  
  - Template: `node-22`

## Next Actions
- **ActionId:** browse-catalog
  - **Label:** Browse the catalog index
  - **OperationId:** catalog_index
  - **Method:** GET
  - **RelativePath:** /v1/catalog
- **ActionId:** search-recipes
  - **Label:** Search published recipes by intent, stack and constraints
  - **OperationId:** search_recipes
  - **Method:** POST
  - **RelativePath:** /v1/catalog/search
  - **Parameters:** {"body":{"limit":5,"query":"Configure S3-compatible access for NestJS"}}
- **ActionId:** plan:page:guides:nestjs:object-client
  - **Label:** Prepare a side-effect-free deployment plan for an authorized project
  - **OperationId:** plan_deployment
  - **Method:** POST
  - **RelativePath:** /v1/catalog/plan
  - **Parameters:** {"body":{"inputs":{},"projectId":"","recipeId":"page:guides:nestjs:object-client","recipeRevision":"r1"}}
- **ActionId:** auth-setup
  - **Label:** Read the existing agent authentication setup
  - **OperationId:** existing_auth_setup
  - **Method:** GET
  - **RelativePath:** /mcp/setup
- **ActionId:** browse:stack:framework-nestjs
  - **Label:** Browse NestJS
  - **OperationId:** browse_node
  - **Method:** GET
  - **RelativePath:** /v1/catalog/nodes/stack%3Aframework-nestjs
- **ActionId:** browse:intent:connect-app-to-storage
  - **Label:** Browse Connect app to storage
  - **OperationId:** browse_node
  - **Method:** GET
  - **RelativePath:** /v1/catalog/nodes/intent%3Aconnect-app-to-storage
- **ActionId:** browse:pattern:browser-file-uploads
  - **Label:** Browse Browser file uploads
  - **OperationId:** browse_node
  - **Method:** GET
  - **RelativePath:** /v1/catalog/nodes/pattern%3Abrowser-file-uploads
