X Enterprises

fastify-xconfig

Fastify configuration plugin for setting up middleware, CORS, rate limiting, and service initialization.

fastify-xconfig

Opinionated configuration plugin that sets up common Fastify middleware in a single registration: CORS, rate limiting, body parsing, compression, and service health checks.

Installation

npm install @xenterprises/fastify-xconfig

Quick Start

await fastify.register(xConfig, {
  cors: {
    origin: ['https://app.example.com'],
    credentials: true,
  },
  rateLimit: {
    max: 100,
    timeWindow: '1 minute',
  },
  compression: true,
})

AI Context

package: "@xenterprises/fastify-xconfig"
type: fastify-plugin
use-when: Bootstrap a new Fastify API — register first before route plugins
sets-up: [CORS, rate limiting, body parsing, compression, health check at /health]
typical-registration-order:
  1. xLogger
  2. xConfig  ← CORS, rate limit, body parser
  3. xAuthBetter or xAuthLocal
  4. domain plugins (xStorage, xEmail, etc.)
  5. routes
Copyright © 2026