API REFERENCE

defineConfig

import { defineConfig, type RasenganServerConfig, type BuildConfig, } from '@rasenganjs/server';

See Config & Build for usage and how config interacts with CLI flags — this page is the flat type reference.

defineConfig()

function defineConfig(config: RasenganServerConfig): RasenganServerConfig;

Typed pass-through helper — returns the same object you pass in, with type-checking. Used in rasengan.server.ts:

rasengan.server.ts
import { defineConfig } from '@rasenganjs/server'; export default defineConfig({ entry: 'src/main.ts', port: 4000, });

RasenganServerConfig

interface RasenganServerConfig { entry?: string; // default "src/main.ts" port?: number; // default 3000 host?: string; // default "0.0.0.0" preset?: 'node' | 'bun' | 'workerd'; // default "node" watchDir?: string | string[]; // default "src/" build?: BuildConfig; }
FieldDescription
entryPath to the server entry file.
portPort the server listens on.
hostHost address to bind to.
presetTarget runtime — "node", "bun", or "workerd" (Cloudflare Workers).
watchDirDirectory (or directories) watched for file changes in rasengan-server dev.
buildProduction build output configuration — see BuildConfig.

Every field the CLI accepts as a flag maps directly to one of these — see CLI for the flag-to-field table.

BuildConfig

interface BuildConfig { outDir?: string; // default "dist" minify?: boolean; // default true formats?: Array<'single-file' | 'directory'>; // default ['single-file', 'directory'] }
FieldDescription
outDirOutput directory for the production bundle.
minifyWhether to minify the bundled output.
formatsWhich output shapes to produce — "single-file" (one server.bundle.mjs) and/or "directory" (one .mjs per source file, preserving structure).

ConfigHolder

class ConfigHolder { static set(config: RasenganServerConfig): void; static reset(): void; static get( overrides?: Partial<RasenganServerConfig> ): Promise<Readonly<RasenganServerConfig>>; }

Static, process-wide config cache used by bootstrap() and the CLI — most apps never call this directly.

MethodDescription
set(config)Seed the cache directly (used by the CLI, which resolves config before spawning the app process).
reset()Clear the cached config — useful in tests, so each test loads a fresh config.
get(overrides?)Resolve the config, then shallow-merge overrides on top. See resolution order below.

get()'s resolution order, first match wins:

  1. An already-cached instance (set via a prior get() or set() call).
  2. The RASENGAN_SERVER_CONFIG environment variable, parsed as JSON.
  3. dist/config.json, if present (the production build output).
  4. rasengan.server.ts/.js, loaded from disk via the CLI's config loader.

Once resolved, the config is frozen and cached process-wide — subsequent get() calls only re-apply overrides, they don't re-resolve from scratch.

Logger
CLI