page:guides:nestjs:cdn assets

Deliver public assets through CDN for NestJS

Summary

Cdn assets for a NestJS app on Ample. Verified on NestJS: a versioned, immutable-cached asset uploaded to a published bucket and served from the CDN URL. Build and start: npm install, nest build (TypeScript) then node dist/main.js on the node-22 template.

Workload

Deliver public assets through CDN

Prerequisites

Resource Requirements

Infrastructure Requirements

Tested Configuration

Input Schema

{  
  "additionalProperties": false,  
  "properties": {    
    "env": {      
      "description": "Encrypted environment variables",      
      "items": {        
        "pattern": "^[A-Z][A-Z0-9_]*=.*$",        
        "type": "string"      
      },      
      "maxItems": 50,      
      "type": "array"    
    },    
    "name": {      
      "description": "App name",      
      "maxLength": 63,      
      "minLength": 1,      
      "pattern": "^[a-z0-9-]+$",      
      "type": "string"    
    },    
    "path": {      
      "description": "Project directory or ample.toml service",      
      "maxLength": 512,      
      "minLength": 1,      
      "type": "string"    
    },    
    "release_command": {      
      "description": "Migration command run before activation",      
      "maxLength": 512,      
      "type": "string"    
    }  
  },  
  "required": [    
    "env",    
    "name",    
    "path"  
  ],  
  "type": "object" 
}

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. Publish a bucket for public assets: Publish only the asset bucket; upload versioned keys with an immutable Cache-Control header and build URLs from its public URL. Command: ample bucket publish
  3. Verify: Fetch the live URL and /p/versioned-static-assets on the example; on failure read the build and runtime logs. Command: ample logs --kind build

Limitations

Cost Estimate

Components

Always-on monthly price of the tested sizes; apps auto-pause when idle. Buckets are allocation-priced per quota and not included.

Examples

Success Checks

  1. App responds on its public URL: HTTP GET on / expecting ample canary nestjs patterns.
  2. Versioned-static-assets check from the example: HTTP GET on /p/versioned-static-assets expecting see the pattern fixture checks.

Evidence Summary

Next Actions