Introduction

Configuration

This guide covers configuring your CellCMS project, including environment variables, asset storage, monitoring, and security best practices.

Environment Variables

Project Configuration

VariableRequiredDefaultDescription
JWT_SECRETYesJWT signing secret. Generate with openssl rand -base64 64
CORS_ORIGINNohttps://studio.cellcms.comAllowed CORS origin
STORAGE_TYPENos3Asset storage backend (s3)
S3_BUCKETNoS3/R2 bucket name
S3_REGIONNoS3 region
S3_ENDPOINTNoCustom S3 endpoint (R2)
S3_ACCESS_KEY_IDNoS3 access key
S3_SECRET_ACCESS_KEYNoS3 secret key

API Variables

VariableDefaultDescription
DATABASE_URLPostgreSQL connection string
JWT_SECRETJWT signing secret
JWT_ACCESS_EXPIRES_IN15mAccess token lifetime
JWT_REFRESH_EXPIRES_IN7dRefresh token lifetime
PORT4000API server port
HOST0.0.0.0API server bind address
CORS_ORIGINhttps://studio.cellcms.comAllowed CORS origin
STORAGE_TYPEs3Asset storage backend

PostgreSQL Configuration

Connection Pool

The API uses a connection pool with these defaults:

SettingValueDescription
max20Maximum connections
idleTimeoutMillis30,000Close idle connections after 30s
connectionTimeoutMillis5,000Fail if connection takes >5s

For high-traffic projects, increase max by setting it in the DATABASE_URL or modifying the pool configuration.

Migrations

Migrations are applied automatically when your project is provisioned. For manual migration:

# Apply the initial schema
psql $DATABASE_URL < migrations/001_initial-schema.sql

# Or use the migration runner
pnpm migrate:up

To rollback:

pnpm migrate:down

Asset Storage

CellCMS stores assets in S3-compatible cloud storage.

S3 Configuration

STORAGE_TYPE=s3
S3_BUCKET=my-cellcms-assets
S3_REGION=us-east-1
S3_ACCESS_KEY_ID=AKIA...
S3_SECRET_ACCESS_KEY=...

Cloudflare R2:

STORAGE_TYPE=s3
S3_BUCKET=cellcms-assets
S3_ENDPOINT=https://YOUR_ACCOUNT_ID.r2.cloudflarestorage.com
S3_ACCESS_KEY_ID=...
S3_SECRET_ACCESS_KEY=...

Monitoring

Health Check

The /api/v1/health endpoint returns:

{
  "status": "ok",
  "timestamp": "2025-01-15T10:00:00.000Z",
  "connections": 3
}

Use this for uptime monitoring and alerting.

Logging

CellCMS uses structured JSON logging (Pino) in production for easy integration with log aggregation services.


Security Checklist

Before going live:

  • Set a strong JWT_SECRET (generated with openssl rand -base64 64)
  • Change the default admin password
  • Set CORS_ORIGIN to your actual Studio domain
  • Review API token permissions (use read-only for frontends)
  • Set up database backups
  • Use S3 storage for assets

Graceful Shutdown

The API server handles SIGTERM and SIGINT signals gracefully:

  1. Stops accepting new connections
  2. Finishes in-flight requests
  3. Closes the database connection pool
  4. Exits cleanly