Skip to main content

config

@rotorsoft/act-root


@rotorsoft/act-root / act/src / config

Function: config()

config(): object

Defined in: libs/act/src/config.ts:141

Gets the current Act Framework configuration.

Configuration is loaded from package.json and environment variables, providing type-safe access to application metadata and runtime settings.

Environment Variables:

  • NODE_ENV: "development" | "test" | "staging" | "production" (default: "development")
  • LOG_LEVEL: "fatal" | "error" | "warn" | "info" | "debug" | "trace"
  • LOG_SINGLE_LINE: "true" | "false" (default: "true")
  • SLEEP_MS: Milliseconds for sleep utility (default: 100, 0 for tests)

Defaults by environment:

  • test: logLevel="error", sleepMs=0
  • production: logLevel="info"
  • development: logLevel="trace"

Returns

object

The validated configuration object

author?

optional author: string | { email?: string; name: string; }

dependencies?

optional dependencies: Record<string, string>

description?

optional description: string

env

env: "development" | "test" | "staging" | "production"

license?

optional license: string

logLevel

logLevel: "fatal" | "error" | "warn" | "info" | "debug" | "trace"

logSingleLine

logSingleLine: boolean

name

name: string

sleepMs

sleepMs: number

version

version: string

Examples

import { config } from "@rotorsoft/act";

const cfg = config();
console.log(`App: ${cfg.name} v${cfg.version}`);
console.log(`Environment: ${cfg.env}`);
console.log(`Log level: ${cfg.logLevel}`);
import { config } from "@rotorsoft/act";

const cfg = config();

if (cfg.env === "production") {
// Use PostgreSQL in production
store(new PostgresStore(prodConfig));
} else {
// Use in-memory store for dev/test
store(new InMemoryStore());
}
// Set via environment variable:
// LOG_LEVEL=debug npm start

// Or check in code:
const cfg = config();
if (cfg.logLevel === "trace") {
logger.trace("Detailed debugging enabled");
}

See

  • Config for configuration type
  • Package for package.json metadata