Skip to Content
Agentlang is open source now!
ReferenceConfiguration

Configuration

Agentlang applications are provided with runtime configuration via the config.al file. Configuration is expressed as a map of values. A minimum configuration looks like:

{"service": {"port": 8080}}

This configures the default port on which the application listens for HTTP requests. Other configurations are:

{"auth": {"enabled": {"type": "boolean", "default": false}}, "rbac": {"enabled": {"type": "boolean", "default": false}}, "auditTrail": {"enabled": {"type": "boolean", "default": false}}, "graphql": {"enabled": {"type": "boolean", "default": false}}, "store": {"type": "map"}}

auditTrail if enabled will audit CRUD operations on an entity whose audit meta is set:

entity Employee { id UUID @id @default(uuid()), address String @optional, email Email @meta {"audit": true} }

The contents of the map passed to store depends on the type of database required. For Postgres, it will be:

{ "type": "postgres", "host": {"type": "string", "default": "localhost"}, "username": {"type": "string", "default": "postgres"}, "password": {"type": "string", "default": "postgres"}, "dbname": {"type": "string", "default": "postgres"}, "port": {"type": "string", "default": "5432"} }

For SQLite:

{"type": "sqlite", "dbname": {"type": "string", "default": "db-<uuid>"}}

As config.al is a valid Agentlang script, each section of the configuration can be declared separately, bound to aliases and then combined into a single config-map. A value in the configuration can be specified as a JavaScript code snippet that reads an environment variable. All this is shown in the following sample:

{ "type": "postgres", "host": "#js process.env.POSTGRES_HOST || 'localhost'", "username": "#js process.env.POSTGRES_USER || 'postgres'", "password": "#js process.env.POSTGRES_PASSWORD || 'postgres'", "dbname": "#js process.env.POSTGRES_DB || 'testdb'", "port": "#js parseInt(process.env.POSTGRES_PORT || '5432')" } @as store { "port": "#js parseInt(process.env.SERVICE_PORT || '8080')" } @as service { "enabled": "#js process.env.AUTH_ENABLED === 'true'" } @as auth { "enabled": "#js process.env.RBAC_ENABLED === 'true'" } @as rbac { "enabled": "#js process.env.GRAPHQL_ENABLED === 'true'" } @as graphql { "enabled": "#js process.env.AUDIT_TRAIL_ENABLED === 'true'" } @as auditTrail { "store": store, "service": service, "auth": auth, "rbac": rbac, "graphql": graphql, "auditTrail": auditTrail }
Last updated on