Configuration

XMS (Multi-Server Orchestration)

Run multiple isolated server instances within a single Node.js process, each with its own ports, security policies, and route scopes.

Process Efficiency

Shared memory and system overhead compared to independent processes.

Network Isolation

Different security levels for Admin vs Public APIs on distinct ports.

Unified Lifecycle

Start, stop, and monitor all services from a single entry point.

Route Scoping

Granular control over which routes are served by which instance.

Basic Configuration

typescript
import { createServer } from "xypriss";

const app = createServer({
  multiServer: {
    enabled: true,
    servers: [
      { id: "public-api", port: 8080, routePrefix: "/api/v1" },
      { id: "admin-panel", port: 8081, routePrefix: "/admin" }
    ]
  }
});

Global Merge Rules

XyPriss implements a Global Merge Rule to reduce redundancy. Root-level options are treated as defaults and deeply merged into each instance.

typescript
const app = createServer({
  // Global settings for all instances
  logger: { level: 'debug' },
  security: { csrf: true },

  multiServer: {
    enabled: true,
    servers: [
      { id: "public", port: 80 }, // Inherits global logger & security
      { id: "internal", port: 81, logger: { level: 'info' } } // Overrides logger
    ]
  }
});

Route Orchestration

Control how routes are distributed across ports using the routePrefixStrategy.

auto-inject

Maps /login to /prefix/login on that port.

strict-match

Only serves routes explicitly defined with prefix.

both

Serves both prefixed and original paths.

Lifecycle Management
When XMS is enabled, app.start() will concurrently boot all configured instances. Ensure your host system has permissions to bind to the requested ports.
Meta Config

Execute arbitrary TypeScript or JavaScript code during the server initialization phase.