Skip to main content

Overview

InsForge Functions provide a secure, scalable serverless compute platform that runs JavaScript/TypeScript code in isolated Deno workers with full access to the InsForge SDK.

Technology Stack

Core Components

ComponentTechnologyPortPurpose
Backend APINode.js/Express7130Function management, authentication, proxy
RuntimeDeno v2.0.67133Secure JavaScript/TypeScript execution
SandboxWeb Workers-Isolated execution environment
DatabasePostgreSQL5432Function code and metadata storage
SDK@insforge/sdk-Pre-injected client for backend access
SecretsAES-256-GCM-Encrypted environment variables

How It Works

When a client makes a request to /functions/{slug}:
  1. The backend API receives and validates the request
  2. Request is proxied to the Deno runtime
  3. Function code is executed in an isolated Web Worker
  4. The function has access to the InsForge SDK and environment variables
  5. Response is returned to the client

Authentication Flow

Performance Characteristics

Execution Limits

LimitValueDescription
Timeout30 secondsMaximum execution time per invocation
MemoryWorker defaultDepends on Deno worker allocation
Payload Size10MBMaximum request/response size
Concurrent WorkersSystem dependentLimited by server resources
Cold Start~50-200msTime to create new worker

Optimization Strategies

  1. Worker Pooling: Workers are created on-demand
  2. Code Caching: Function code cached in memory
  3. Secret Caching: Decrypted secrets cached per execution
  4. SDK Reuse: SDK client created once per worker

Best Practices

  1. Keep Functions Small: Single responsibility per function
  2. Handle Errors Gracefully: Always return proper HTTP responses
  3. Validate Input: Check request data before processing
  4. Use Caching: Cache frequently accessed data
  5. Optimize Queries: Use efficient database queries
  6. Monitor Performance: Track execution times and errors
  7. Secure Secrets: Never log sensitive data
  8. Test Locally: Test functions before deployment