Configuration
The fields of antelope.config.ts. Modules and their sources, interface bindings, environment overrides, templates, config variables, environments, and logging.
Configuration file
A standalone project reads antelope.config.ts at the project root. The file selects the modules and passes settings to them. An embedded host passes plain JavaScript values to createRuntime() instead.
| Task | Configuration mechanism |
|---|---|
| Load local code or a published provider | Module sources |
| Select among providers of one interface | importOverrides and exportPriority |
| Supply a secret or deployment-specific value | envOverrides |
| Change several settings for staging or production | environments |
| Reuse a value from the same configuration | ${path} templates |
| Read a value another module computes before construction | Module config variables |
The smallest configuration names the project and declares its modules:
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-project",
modules: {
// Module definitions
},
});
defineConfig types the configuration, so the TypeScript compiler checks every field.
Dynamic configuration
The file can export a function instead of an object. The function receives a context whose env field holds the selected environment, so one file can return different settings per deployment target.
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig((ctx) => ({
name: "my-project",
modules: {
"my-module": {
source: { type: "local", path: "./modules/my-module" },
config: {
apiUrl:
ctx.env === "production"
? "https://api.prod.com"
: "http://localhost:3000",
},
},
},
}));
Full configuration reference
The top-level object has these fields. Only name is required.
import type {
AntelopeLogging,
AntelopeModuleConfig,
AntelopeTestConfig,
} from "@antelopejs/interface-core/config";
interface AntelopeConfig {
name: string; // Project name
cacheFolder?: string; // Default: ".antelope/cache"
modules?: Record<string, string | AntelopeModuleConfig>; // Module definitions
logging?: AntelopeLogging; // Logging configuration
envOverrides?: Record<string, string | string[]>; // Environment variable mappings
environments?: Record<string, Partial<AntelopeConfig>>; // Per-environment overrides
test?: AntelopeTestConfig; // Test configuration
}
Field checks at load
A wrong type stops the command, and the error names the field. The core first checks the exported value against AntelopeConfig, environments included, before templates run. A boolean or number field holds a literal there. To set one from the environment, use envOverrides.
Configuration field 'name' in /app/antelope.config.ts does not hold a string.
It checks again after templates and environment overrides:
Configuration field 'modules.api.source.version' does not hold a string after templates and environment overrides.
Undeclared keys and a module's config are not checked. The module receives its config as config variables and templates leave it.
Module definitions
A module entry is either a version string or an object with a source, a config, and binding rules.
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-project",
modules: {
// Shorthand: npm package with version
"my-module": "1.0.0",
// Full configuration
"my-other-module": {
source: { type: "local", path: "./modules/my-module" },
config: { port: 3000 },
importOverrides: { "@antelopejs/interface-database": "mongodb-module" },
disabledExports: ["@antelopejs/interface-legacy"],
},
},
});
The shorthand "my-module": "1.0.0" is a package source whose package name is the entry key and whose version is the string. An object with a version and no source expands the same way. An object with neither stops the load with an error on modules.<name>.source. Use the object form for local or Git sources, a module config, import overrides, or disabled exports.
The object form has two more flags. disabled: true keeps the entry and its config in the file but leaves the module out of the project. optional: true loads the module after the others have started. If an optional module fails to download, construct, or start, the core logs the failure and the project runs without it.
Module source types
The source type tells the core where the module code is and how to load it.
| Type | Description |
|---|---|
local | Local filesystem path to a TypeScript or JavaScript project. |
local-folder | Parent folder whose immediate subdirectories are modules. |
package | npm package fetched from a registry. |
git | Git repository cloned and built. |
Local source
A local source points to a module on your filesystem. With --watch, the core watches the configured directories for changes. A hand-written local source runs only the commands you give it. It does not infer a TypeScript build.
{
type: "local",
path: "./modules/my-module", // Relative path to the module
main: "custom-entry.js", // Custom entry point (optional)
watchDir: ["src", "lib"], // Directories to watch (optional, string or string[])
installCommand: "pnpm exec tsc", // Command to run when loading (optional, string or string[])
reloadCommand: "pnpm exec tsc" // Command to run on hot reload (optional, string or string[])
}
A path that starts with ~/ starts in your home folder, and so does one that starts with ~\ on Windows. A ~ anywhere else is part of a name and stays as written, so a Windows short path such as C:\Users\RUNNER~1\modules\api works unchanged.
Install the dependencies in the module directory first. Commands run in that directory. On hot reload, the core runs reloadCommand when it is set, and installCommand again otherwise. The local sources that the CLI scaffolds include build commands. A hand-written source must supply its own.
Package source
A package source fetches a module from an npm registry. The core downloads the package and caches each version in its own folder.
{
type: "package",
package: "@scope/my-module",
version: "1.0.0"
}
The version field accepts an exact version, an npm semver range (^1.0.0, ~1.2.0, 1.x), or a dist-tag (latest, next). The core serves an exact version from the cache without contacting the registry. It resolves a range or a dist-tag against the registry on every run, so the cache picks up a newer matching version as soon as one is published. If the registry is unreachable, the core falls back to the highest cached version that still satisfies the range.
When the project has a lock for the module in antelope-lock/, the core resolves a range to the recorded version without contacting the registry, and installs the dependencies of the module from that lock. ajs project modules update moves both. Module locks describes the locks.
Git source
A git source clones a module from a Git repository. You can pin a branch or a commit.
{
type: "git",
remote: "https://github.com/user/repo.git",
branch: "main", // optional
commit: "abc123", // optional
installCommand: "npm install && npm run build" // optional
}
Local folder source
A local-folder source loads every immediate subdirectory of a parent folder as a module. Use local for one module. local-folder is the grouped form, which the CLI also offers as --mode dir. The core treats each subdirectory as a module, so keep unrelated directories out of the folder.
modules/ ← local-folder points here
├── billing/ ← local points here for billing only
│ ├── package.json
│ └── dist/index.js
└── notifications/
├── package.json
└── dist/index.js
{
type: "local-folder",
path: "./modules",
watchDir: "src", // optional
installCommand: "pnpm build", // runs in each module directory
reloadCommand: "pnpm build" // runs instead of installCommand on hot reload
}
Install the dependencies of each module first. Neither local source type compiles code. Each runs only the commands you configure.
Interface bindings
When several modules implement the same interface, each module that uses the interface is bound to one of them. The binding is fixed when the module imports the interface. The core evaluates the interface once per provider, and every object built from that copy (a query, a schema, an event handler registration) reaches that provider wherever the object is used.
Pinning a provider
importOverrides pins an interface to a provider module:
{
importOverrides: {
"@antelopejs/interface-database": "mongodb-module"
}
}
A module may pin interfaces it does not import itself. The pin is carried down in two directions. It reaches the standalone interfaces the module uses, such as a data-api built on the pinned database. It also reaches the modules that provide the interfaces the module uses, as far down as some module still needs the interface. Pinning the top-level module of a tree is usually enough.
For each interface, the core binds a module to the first match in this order:
- The module itself, when it implements the interface.
- The module's own pin.
- The pin carried from its nearest pinned ancestor.
- The default provider.
Default provider
With a single provider, that provider is the default. With several, the default is the provider with the highest exportPriority for the interface. On a tie, the alphabetically first provider wins.
{
modules: {
"mongodb-module": {
exportPriority: { "@antelopejs/interface-database": 1 },
},
},
}
An interface missing from exportPriority has priority 0. Priorities are integers, and the core rejects any other number at load. A higher priority favors a provider. A negative priority makes a provider less preferred, not ineligible. It still wins when it is the only provider or when every other priority is lower. When several providers tie, the core logs a warning and picks the alphabetically first one. Pin the consumer when that choice matters.
Conflicts
A module can be reached through two paths that carry different bindings for an interface it needs. The bindings differ when the paths carry two different pins, or a pin on one path and the default on the other. Startup then stops with an error that names the module. Pin the interface on that module to resolve the conflict.
Connections
Further importOverrides entries for the same interface, each with an id, give a module several connections:
{
importOverrides: [
{ interface: "@antelopejs/interface-database", source: "mongodb-module", id: "main" },
{ interface: "@antelopejs/interface-database", source: "postgres-module", id: "external" },
{ interface: "@antelopejs/interface-data-api", id: "external" },
],
}
The first entry for an interface is the pin that a plain import reaches. GetInterfaceInstance(interfaceName, id).path names the copy of the interface bound to that connection. Pass it, or one of its subpaths, to require() to build objects bound to that provider. An entry without a source declares a connection to a standalone interface. In the example, the third entry is the data-api built on the external database.
Disabled exports
disabledExports stops a module from providing the listed interfaces. The module still loads and runs, but the core does not register those interfaces from it.
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-project",
modules: {
"legacy-module": {
source: { type: "local", path: "./modules/legacy" },
disabledExports: ["@antelopejs/interface-legacy"],
},
},
});
Environment variable overrides
envOverrides maps environment variable names to configuration paths in dot notation. When a listed variable is set, the core writes its value at each mapped path when it loads the configuration.
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-project",
modules: {
"db-module": {
config: { host: "localhost", port: 5432 },
},
},
envOverrides: {
DB_HOST: "modules.db-module.config.host",
DB_PORT: "modules.db-module.config.port",
},
});
With this configuration, DB_HOST=db.prod.com replaces the host value in the db-module config. The core writes the variable's text as it is. DB_PORT=5433 sets port to the string "5433", not to a number.
A few project fields hold a boolean or a number, and the core decodes the text for them:
| Path | Accepted text |
|---|---|
logging.enabled, logging.moduleTracking.enabled | true or false |
modules.<name>.optional, modules.<name>.source.ignoreCache | true or false |
modules.<name>.exportPriority.<interface> | A finite number, such as 10 |
Any other text for these paths stops the load with an error that names the field. An override that writes text into another project field that is not a string, such as importOverrides, fails the field checks too. A value that maps to an array of paths is written at every path. Overrides keep secrets and deployment-specific values out of the configuration file.
The project's .env
Before it evaluates the configuration, the core reads the .env file next to antelope.config.ts. Both envOverrides and the configuration body see its variables. A variable that the process environment already holds keeps its value, so .env only fills in the missing ones. The core reads the file on every load of the configuration (ajs project dev, ajs project build, and the ajs project modules commands) and when ajs project start starts a build.
With ajs project dev --watch, an edit of .env restarts the project, as an edit of antelope.config.ts does. Creating or deleting the file counts as an edit. The restart reads the file again. A variable removed from .env is unset, unless something else changed it in the meantime.
Overrides in a build
ajs project build stores the envOverrides mapping in build.json and none of its values: it resolves the configuration as if every mapped variable were unset. ajs project start reads the mapped variables from the environment it starts in, its .env included, and applies them to the configuration the build stored. A variable set at build time and unset at start leaves the configured value.
An override of a module's source, name or cacheFolder decides what the build downloads and where, so it applies at build time and build.json records the source it resolved. Keep secrets out of these fields. A ${path} template that reads an overridden path takes the configured value in a build, not the variable. So does a configuration body that reads process.env itself.
A build stores every other value it resolves, including what the configuration body reads from process.env or .env. Map secrets through envOverrides, or start with ajs project start --refresh-config, which resolves the whole configuration at startup without rewriting the build artifact.
Template substitution
A string value can reference another value of the configuration with ${path}. The core resolves the references after it applies environment overrides and before it passes the config to the module.
{
config: {
host: "localhost",
port: 5432,
url: "${host}:${port}/mydb" // Resolves to "localhost:5432/mydb"
}
}
path is either a full dot path from the top of the configuration, such as modules.db-module.config.port, or a bare key. A bare key matches the last string, number, or boolean with that key anywhere in the configuration, so give shared keys distinct names. A reference that makes up the whole string keeps the value's type, so "${port}" becomes the number 5432. A string project field, such as name or a module source's version, may hold a reference, and the field checks refuse one that resolves to another type. A boolean or number project field holds its literal value, since the file is checked before templates run. A module's config takes the value as it is. Inside a longer string, an unknown reference becomes an empty string. A whole-string reference to an unknown path stays as written.
References of the form ${@<module>.<VAR_NAME>} belong to the reserved config variables namespace. Template substitution leaves them untouched. The core resolves them later, once the provider module has published them.
Module config variables
Some values exist only at run time, such as the port a server bound or a generated secret, so the configuration file cannot contain them. A module can publish such a value as a config variable, and other modules reference it from their own config.
Declaring and publishing
The provider declares the names it publishes in its package.json (or antelope.module.json), under antelopeJs.configVars:
{
"name": "api",
"antelopeJs": {
"configVars": ["API_PORT"]
}
}
It then returns the values from its provide callback, a lifecycle step that runs before any module constructs:
import type { ConfigVars } from "@antelopejs/interface-core/config";
declare function reservePort(config: unknown): Promise<number>;
export async function provide(config: unknown): Promise<ConfigVars> {
const port = await reservePort(config);
return { API_PORT: port };
}
reservePort stands for your own port allocation. Its declare line only gives it a type. A published value is a string, a number, or a boolean. Anything else, null included, fails the provider.
provide is optional, and only providers implement it. construct cannot publish config variables. The core ignores whatever construct returns.
A provider must compute its values on its own. No module has constructed when provide runs, so awaiting another module's interface from provide deadlocks the startup. The core does not support that pattern. The core interfaces registered before the module lifecycle starts, including GetRuntimeInfo(), stay available and are enough to derive a port, a base URL, or a secret. A provider may still read a variable that another provider publishes, through its own config. The core orders those provider-to-provider links for you.
Referencing
A consumer references a published value with ${@<module>.<VAR_NAME>}, where <module> is the provider's key in modules:
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-project",
modules: {
api: { source: { type: "local", path: "./modules/api" } },
dms: {
source: { type: "local", path: "./modules/dms" },
config: {
apiBaseUrl: "http://127.0.0.1:${@api.API_PORT}", // "http://127.0.0.1:5010"
servers: [{ port: "${@api.API_PORT}" }], // 5010, as a number
},
},
},
});
A reference that makes up the whole string keeps the published type, so a number stays a number. A reference inside a longer string is interpolated. Substitution reaches every depth of the configuration, arrays included. It leaves every other value as it was, so a RegExp, a Date, or a class instance in the config comes out untouched.
Resolving without running the provider
provide runs only when the project starts. A tool that reads the project without starting it cannot call provide. One such tool is ajs dms build, which builds the DMS frontend from antelope.config.ts and the installed modules. If a provider derives its values from its configuration alone, it can declare a pure function that computes them, under antelopeJs.configVarsFile:
{
"name": "api",
"antelopeJs": {
"configVars": ["API_PORT"],
"configVarsFile": "dist/config-vars.js"
}
}
The file exports configVars(config). The function returns the declared variables from the provider's configuration and does nothing else: no socket, no interface call, no runtime information. The module's provide reuses it, so both paths compute the same values:
import type { ConfigVars } from "@antelopejs/interface-core/config";
export function configVars(config: Config): ConfigVars {
return { API_PORT: config.port };
}
import type { ConfigVars } from "@antelopejs/interface-core/config";
import { configVars } from "./config-vars";
export async function provide(config: Config): Promise<ConfigVars> {
const port = await reservePort(config);
return configVars({ ...config, port });
}
Anything that only provide knows stays in provide, such as a port that fell back because the requested one was taken, or a check that fails the boot. The function returns what the configuration says. The core never calls it. At run time, the values are always the ones provide returned.
Resolution order
The core reads every declaration before it runs anything, so it knows the graph of providers and consumers in advance:
- Providers publish their variables in the
providephase. Providers that read no variable publish first, concurrently. A provider that reads from another one waits for it. - The core substitutes the published values into the config of every module that references them.
- Every module then constructs, all at once, as it would without config variables.
The variable graph never orders construction, and it must not. The interface graph orders modules the other way round. A module that serves an interface its peers call from their own construct has to construct alongside them. Staging construction on the variables would make the two orders wait on each other.
The core resolves the values once and freezes them. It does not propagate a value that changes after startup.
Failure modes
Each of these situations is a hard error that names the module and the reference:
| Situation | When |
|---|---|
| A reference to a module that is not loaded | Before anything runs |
| A reference to a variable the provider does not declare | Before anything runs |
A cycle in the graph (api -> dms -> api) | Before anything runs |
A declared variable the provide callback did not return | After the provider published |
A provider whose provide failed | Its consumers are reported as failed and are never constructed with an unresolved config |
An unresolved reference never becomes an empty string.
A module skipped because its provider failed still owes the interfaces it declared. Its peers do not read config variables from it. They call it. The async proxies of those interfaces therefore reject instead of waiting, and the rejection names the module that never constructed and the interface. A boot that ends in failures reports them and exits with a non-zero code, even when a module bound a socket before its peer threw.
Environment-specific configuration
environments holds per-environment overrides. Each key is an environment name. Its value is a partial configuration that the core merges on top of the base configuration when that environment is selected.
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-project",
modules: {
"api-module": {
config: { port: 3000 },
},
},
environments: {
production: {
modules: {
"api-module": {
config: { port: 8080 },
},
},
},
},
});
Select an environment with -e (--env), or set ANTELOPEJS_LAUNCH_ENV:
ajs project dev -e production
The core applies the base configuration first and merges the environment block on top. The block overrides only the fields it sets. Every other field keeps its base value.
When environments is declared, the valid names are default and the declared keys. An unknown name is a usage error (exit code 2), and the CLI lists the accepted names. Without an environments map, the CLI accepts any name, and a configuration function can read ctx.env to choose its settings.
Logging configuration
The logging section sets which modules and channels print, the minimum severity per channel, and the date format.
{
logging: {
enabled: true,
moduleTracking: {
enabled: true,
includes: ["my-module"], // Only show logs from these modules
excludes: ["noisy-module"] // Hide logs from these modules
},
channelFilter: {
"main": "info", // Level name or number
"http": 10, // DEBUG level
"db:*": "warn" // Prefix wildcard
},
dateFormat: "yyyy-MM-dd HH:mm:ss"
}
}
The Logging page describes the severity levels, channels, and filtering options.
Complete configuration example
This example combines the mechanisms on this page. The package versions, module names, credentials, and remote repositories are placeholders, so the example is not a runnable application template. For a first working project, follow the Quick Start.
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
// Project name, shown in logs and CLI output
name: "my-fullstack-app",
// Directory for cached modules; build.json lives separately in .antelope/build
cacheFolder: ".antelope/cache",
modules: {
// Shorthand: a version string resolves to { type: "package", package: <key>, version }
"@antelopejs/auth-jwt": "^1.0.0",
// Local source: a module on disk, with a watch directory for live reload
"api-module": {
source: {
type: "local",
path: "./modules/api",
watchDir: ["src"],
installCommand: "npm install",
},
config: {
port: 3000,
host: "localhost",
url: "${host}:${port}", // template substitution, resolves to "localhost:3000"
},
importOverrides: {
"@antelopejs/interface-database": "mongodb-module",
},
disabledExports: ["@antelopejs/interface-legacy-api"],
},
// Git source: clone a module from a remote repository
"analytics-module": {
source: {
type: "git",
remote: "https://github.com/your-org/analytics-module.git",
branch: "main",
installCommand: "npm install && npm run build",
},
config: {
trackingId: "UA-000000-1",
},
},
// Package source (explicit form): fetch from an npm registry
"mongodb-module": {
source: {
type: "package",
package: "@antelopejs/mongodb",
version: "~1.8.4",
},
config: {
url: "mongodb://localhost:27017",
database: "app_dev",
},
},
},
// Map environment variables to configuration paths in dot notation
envOverrides: {
DB_URL: "modules.mongodb-module.config.url",
DB_NAME: "modules.mongodb-module.config.database",
// One variable can override several paths
API_HOST: [
"modules.api-module.config.host",
"modules.analytics-module.config.endpoint",
],
},
// Per-environment overrides, merged on top of the base configuration
environments: {
production: {
modules: {
"api-module": {
config: { port: 8080, host: "0.0.0.0" },
},
"mongodb-module": {
config: {
url: "mongodb://db.prod.internal:27017",
database: "app_prod",
},
},
},
logging: {
enabled: true,
channelFilter: { main: "warn", http: "warn", "*": "warn" },
},
},
staging: {
modules: {
"mongodb-module": {
config: {
url: "mongodb://db.staging.internal:27017",
database: "app_staging",
},
},
},
},
},
// Console output for all modules
logging: {
enabled: true,
moduleTracking: {
enabled: true,
includes: ["api-module", "mongodb-module"],
excludes: [],
},
channelFilter: {
main: "info",
http: 10,
},
dateFormat: "yyyy-MM-dd HH:mm:ss",
},
});
Key takeaways
- A version string as a module entry is a
packagesource whose package name is the entry key. envOverrideskeeps secrets and deployment-specific values out of the file. SetDB_URLin your shell or CI environment, and the core writes it into themongodb-moduleconfig.environmentskeeps development, staging, and production in one file. An environment block overrides only the fields it sets.- A template such as
${host}:${port}builds a derived string from other values in the configuration. - A config variable such as
${@api.API_PORT}references a value another module publishes fromprovidebefore any module constructs. The runtime value lives in one place instead of in several module configs.
See also
- CLI config commands to manage the configuration from the command line
- Quick Start to create a first project