Infrastructure Overview
Database, events, jobs, queue, cache, file storage, sessions, vault, and logging
Arcway provides built-in infrastructure services accessible through the handler context (ctx). Every route handler, event listener, and job handler receives these services automatically.
Handler Context
Route handlers, event listeners, and jobs all receive a ctx object with infrastructure services:
// Available in ctx:
{
db, // Knex database connection
events, // Event emitter (emit, subscribe)
queue, // Persistent queue (push, pop, remove)
cache, // Key-value cache (get, set, delete, wrap)
files, // File storage (write, read, delete, list, exists)
mail, // Email (send, queue)
log, // Logger (debug, info, warn, error)
}In route handlers, ctx also includes req (request data). In event listeners, ctx includes event (event info). In jobs, ctx includes payload.
Services
- Database — Knex-based SQL database with migrations, seeds, transactions, and schema introspection.
- Events — Asynchronous event bus for decoupling business logic with file-based listeners.
- Jobs — Background tasks with cron scheduling, retries, concurrency control, and rate limiting.
- Queue & Cache — Persistent FIFO queue and key-value cache with multiple driver backends.
- File Storage — File read/write/list/delete with local and S3 drivers.
- Mail — Email sending (SMTP) and receiving (IMAP) with background queue support.
- Sessions & Auth — Cookie-based encrypted sessions and crypto utilities (passwords, JWT, encryption).
- Logging — Structured logging with Pino, request tracing, and queryable log buffer.