Skip to content

Configuration

Backflow uses a JSON configuration file to define your entire API.

Basic Structure

json
{
  "supabase": { },
  "firebase": { },
  "jwt": { },
  "routes": [ ],
  "credentials": { },
  "cache": { },
  "rateLimit": { },
  "agent": { }
}

Database Configuration

Supabase

json
{
  "supabase": {
    "url": "{{env.SUPABASE_URL}}",
    "anonKey": "{{env.SUPABASE_ANON_KEY}}"
  }
}

Firebase

json
{
  "firebase": {
    "projectId": "{{env.FIREBASE_PROJECT_ID}}",
    "clientEmail": "{{env.FIREBASE_CLIENT_EMAIL}}",
    "privateKey": "{{env.FIREBASE_PRIVATE_KEY}}"
  },
  "databaseProvider": "firebase"
}

SQLite

json
{
  "sqlite": {
    "dbPath": "./data/app.db"
  },
  "databaseProvider": "sqlite"
}

Authentication

JWT

json
{
  "jwt": {
    "secret": "{{env.JWT_SECRET}}"
  }
}

Firebase Auth

Routes can use Firebase Auth instead of JWT:

json
{
  "routes": [{
    "path": "/profile",
    "method": "get",
    "authProvider": "firebase"
  }]
}

Template Variables

Use templates to inject dynamic values:

TemplateSourceExample
{{env.VAR}}Environment variable{{env.API_KEY}}
{{secret:key}}Tenant secret{{secret:openai_key}}
{{body.field}}Request body{{body.title}}
{{params.id}}URL parameter{{params.id}}
{{query.search}}Query string{{query.search}}
{{auth.sub}}JWT subject{{auth.sub}}

Tenant Overrides

Tenants can override base {{env.VAR}} values with their own secrets using {{secret:key}}. See Tenant Secrets for details.

Cache Configuration

json
{
  "cache": {
    "enabled": true,
    "provider": "redis",
    "redis": {
      "url": "{{env.REDIS_URL}}"
    },
    "ttl": 3600,
    "maxSize": 10000
  }
}

Providers: memory, redis, sqlite

Rate Limiting

json
{
  "rateLimit": {
    "enabled": true,
    "default": {
      "windowMs": 60000,
      "max": 100
    },
    "perEndpoint": {
      "/api/heavy": {
        "windowMs": 60000,
        "max": 10
      }
    }
  }
}

Full Example

json
{
  "supabase": {
    "url": "{{env.SUPABASE_URL}}",
    "anonKey": "{{env.SUPABASE_ANON_KEY}}"
  },
  "jwt": {
    "secret": "{{env.JWT_SECRET}}"
  },
  "cache": {
    "enabled": true,
    "provider": "redis",
    "redis": { "url": "{{env.REDIS_URL}}" }
  },
  "rateLimit": {
    "enabled": true,
    "default": { "max": 100 }
  },
  "routes": [
    {
      "path": "/users",
      "method": "get",
      "supabaseQueries": [{
        "table": "users",
        "operation": "select"
      }]
    }
  ]
}

Released under the ISC License.