Interfaces
@system-inc/base-foundation · 515c140 · 16 symbols
BaseModuleCreate
Specification for creating a Base module.
Members
key:BaseModuleKey<ModuleSpecificSettings>The module's identity key — the same
BaseModuleKeyconsumers use withuses,configuration.getModuleSettings(key), and declared module membership (@Injectable(key)). Passing the key (not a string) makes it the single source of the module's name AND binds the key's phantom settings type to this module's settings, so a key declared asBaseModuleKey.create<StripeModuleSettings>('Stripe')only accepts settings of that shape.settings:ModuleSettings<ModuleSpecificSettings>Settings for this module.
uses?:readonly ModuleUse[]A list of modules that this module uses. Entries may be feature-scoped (
{ module, when }).onCreate(settings:ModuleSettings<ModuleSpecificSettings>):voidCalled when the module is created.
onInitialize(settings:ModuleSettings<ModuleSpecificSettings>,configuration:BaseConfiguration):Promise<void>Called when the module is initialized.
BaseModuleOptions
Registration modifiers a worker applies when adding a module — the single, uniform way to change how a module participates in this worker. Apply them with BaseModule.with (or pass to BaseModule.create); they are applied once, when the app manifest is flattened.
- Feature toggles (
orm/eventBus/graphql/queue/router/rpc/scheduled/middleware/webSocket): set tofalseto strip that feature's wiring for this registration — e.g.middleware: falsekeeps a module's services but drops its global/handler middleware (which otherwise runs on every request, even where you only wanted the services). A{ module, when }entry inuseswhosewhennames a stripped feature is dropped too. Toggles control wiring, not the bundle: the stripped code is still imported and shipped (only its registration is skipped). To drop the code itself, import a smaller module/layer instead. externalSchema: register the module's entities for queries but do NOT own/migrate their schema here — another worker (or an inheritSchema source) owns it. The entities still build into the runtime query schema; they're excluded from migration generation and the schema:sync table scope.database: route this module to a named database in this worker. It overrides the module's ownsettings.orm.databaseName, so a module reused across workers can live in different databases per deployment (e.g. the default database in the main worker, but an externalconnecteddatabase inside a Durable Object whose default database is local SQLite). It governs both where the module's entities are registered AND where the module's services' token-less@InjectRepository/@InjectDatabaseresolve to — see module-aware resolution in BaseModuleSettings.orm / the orm doc. Typically paired withexternalSchema: true.
See BaseModuleSettings for the features these map to.
Members
database?:stringeventBus?:booleanexternalSchema?:booleangraphql?:booleanmiddleware?:booleanorm?:booleanqueue?:booleanrouter?:booleanrpc?:booleanscheduled?:booleanwebSocket?:boolean
BaseModuleSettings
An interface for defining all modules settings in Base.
Modules are self-contained pieces of functionality that can be used in multiple places. You can combine the functionality of multiple modules by using them together in your Workers.
Members
accessControl?:AccessControlSettingsAccess-control settings for this module. A module that implements the worker's identity system contributes its import('../access-control/SessionContextProvider').SessionContextProvider here; exactly one provider may be registered across the worker and all its modules.
cli?:{ configValidators?: WorkerConfigValidator[] }CLI-time extension points for the module.
graphql?:{ directives?: GraphQLDirective[] }GraphQL settings for this module. Resolvers are contributed through the unified
servicesarray (sorted in by their@GqlResolverdecorator); this slot carries what can't be a class list.middleware?:{ global?: BaseMiddlewareRegistration[]; handler?: HandlerMiddlewareRegistration[] }Middleware settings for this module.
orm?:{ databaseName?: string; entities?: OrmEntityClass[]; externalEntities?: OrmEntityClass[] }Orm settings for this module.
services?:(Constructor<object>)[]The classes this module provides to the system — the single class slot. Each class's decorators declare what it is: dispatch decorators (
@GqlResolver,@HttpService,@RpcService,@WorkerQueueProcessor,@ScheduledExecutable,@EventBusListener) sort it into the matching dispatch surface(s) at boot, honoring this registration's feature toggles;@Providerhosts and injectable-family classes are loaded so their registrations run. A class with no recognized base decorator is a boot error — it can't do anything, so listing it is a mistake (usually a forgotten decorator). Configuration-carrying settings (directives, webSocket delegates, middleware) stay in their subsystem slots; entities go inorm.entities.webSocket?:{ delegates?: WebSocketDelegateSettings[]; mappings?: (WebSocketContextMapping<Json>)[] }
BaseSettings
The BaseSettings interface provides configuration for your Base Worker. Each of these fields can be optionally set by implementing this interface.
Members
accessControl?:AccessControlSettingsThe access-control settings for the Base Worker — registers the worker's
SessionContextProvider(apps whose identity system lives in a module register it through that module's settings instead).cli?:{ configValidators?: WorkerConfigValidator[] }CLI-time extension points for the worker.
containers?:CfDurableObjectSettings[]The settings for Cloudflare Containers.
delegate?:Constructor<BaseWorkerDelegate>A delegate for receiving events from the Base Worker.
deployEnvironment?:string | string[]The environment or list of environments that this worker should be deployed to.
durableObjects?:CfDurableObjectSettings[]The settings for Cloudflare Durable Objects.
graphql?:GqlSettingsThe GraphQL settings for the Base Worker (provider type, route, directives, graphiql/introspection). Resolver classes go in
services.keyValueStorage?:KeyValueStorageSettingsThe settings for the key value storage this Base Worker can access.
logging?:LoggingSettingsLogging settings — the default and per-category log thresholds and the request-log switch. The
LOG_LEVELenvironment variable overrides the thresholds at deploy time.middleware?:{ global?: BaseMiddlewareRegistration[]; handler?: HandlerMiddlewareRegistration[] }Middleware settings for this module.
modules?:(BaseModule<any>)[]The list of modules to load for the Base Worker.
moduleTest?:boolean | string[]Opt-in for running module integration tests with this worker.
- true: run integration tests for ALL modules this worker registers
- string[]: run integration tests only for the listed module names
- undefined (default): no module integration tests
name:stringThe name of the Base Worker.
objectStore?:ObjectStoreSettingsThe settings for object storage (R2 / S3-compatible buckets) this Base Worker can access. Buckets declared here can be injected via
@InjectObjectStore(...)without requiring theFileStoragemodule.orm?:NamedConfiguration<OrmSettings<"drizzle">>The settings for the ORM this Base Worker can access.
queue?:WorkerQueueSettingsThe queue settings for the Base Worker.
router?:RouterSettingsThe router settings for the Base Worker (CORS, rewrites). Route handler classes go in
services.rpc?:RpcSettingsThe RPC settings for the Base Worker.
scheduled?:ScheduledSettingsThe cron settings for the Base Worker.
server?:NamedConfiguration<BaseServerSettings>Settings for the local development server.
services?:(Constructor<object>)[]The classes this worker contributes — the single class slot. Each class's decorators declare what it is: dispatch decorators (
@GqlResolver,@HttpService,@RpcService,@WorkerQueueProcessor,@ScheduledExecutable,@EventBusListener) sort it into the matching dispatch surface(s) at boot;@Providerhosts and injectable-family classes are loaded so their registrations run. A class with no recognized base decorator is a boot error. Configuration-carrying settings (cors, rpc visibility, webSocket delegates, middleware, directives) stay in their subsystem slots; entities go inorm.title:stringThe title of the project.
version:stringThe version of the Base Worker.
webSocket?:WebSocketSettingsThe WebSocket settings for the Base Worker.
BaseWorkerDelegate
Delegate in charge of configuring the Base application and optionally responding to lifecycle events.
Members
onInitialize(base:Base):Promise<void>Optional hook to run after Base has been initialized. This is where you can add routes, middleware, etc. that are specific to your application, but also not configurable in the BaseSettings.
onStart():Promise<void>Called when the worker starts listening for requests. Not called on all platforms.
onStop():Promise<number | void>Called when the worker stops listening for requests. Not called on all platforms.
BaseWorkerPlatformDelegate
Delegate for platform-specific worker functionality.
Members
getPlatformRequestProperties(request:Request):PlatformRequestProperties | undefinedGets properties that have been added to the request that are specific to the platform. For example, Cloudflare adds additional headers to the request that can be used to determine the country of the request.
getRequestIpAddress(request:Request):string | undefinedGets the IP address from the request.
initializePlatform(configuration:BaseConfiguration):void | Promise<void>Perform any platform-specific initialization.
EnvironmentVariables
A default set of environment variables for Base.
You can extend this interface to add your own variables specific to your Worker.
These variables will be available to your worker at runtime, and should match the variables you have set in your env.toml file.
extends Dictionary<unknown>
Members
BUILD_TIMESTAMP?:stringThe build timestamp of the build.
CF_VERSION_METADATA?:anyCloudflare Worker version metadata.
COMMIT_SHA?:stringThe commit SHA of the build.
DATABASES?:string | DatabaseEnvironmentVariables[]A list of databases to connect to. Each database should have a name and a URL. The URL should be formatted as a MySQL connection string.
DEPLOYED_BY?:stringThe user who deployed the build.
ENCRYPTION_KEYS?:string | ExportedEncryptionKey[]The encryption keys to use for the server.
ENVIRONMENT?:stringThe type of environment you are running in. This should map to one of the possible types in EnivronmentType in base/source/core/Environment.ts
EXECUTION_MODE?:ExecutionModeTypeThe execution mode of the worker.
PLATFORM?:PlatformTypeThe type of platform the worker is running on.
PORT?:stringThe port the worker should run on.
RUN_CONFIG?:stringThe configuration name to use when running the worker.
EventBusConfiguration
Runtime event-bus configuration: the @EventBusListener classes the
manifest aggregated.
Members
listeners:(Constructor<BaseEventListener<BaseEvent>>)[]
LoggingConfiguration
Runtime logging configuration: the settings-level defaults (level +
per-category overrides), the LOG_LEVEL environment directive (which
wins where both are set — the engine applies it last at boot), and the
request-log switch with its default applied.
extends LoggingSettings
Members
categories?:Record<string, LogLevel>Per-category thresholds overriding
level, keyed by the category name passed toLogger.create(e.g.{ rpc: LogLevel.Debug }). The framework's own categories includebase,http,rpc,gql,orm,queue,scheduled,ws,event,kv,durable,common.directive?:stringlevel?:LogLevelThe default log threshold. Defaults to
LogLevel.Info.requestLog:booleanWhether to emit the per-request log line (
GET /notes 200 OK (12ms)). Defaults to true. This is a request log, not an application log — it is the single most expensive log line on the hot path, so it has its own switch: turn it off for maximum throughput while keepinginfoelsewhere.
RouterConfiguration
Router settings for Base applications.
extends RouterSettings
Members
cors?:RouterCorsSettingsCors settings for the router.
disableAccessLog?:boolean | string[]A map of routes that should not be logged or true to disable for all routes.
rewrite?:Record<string, string>A map of paths to rewrite to other paths.
services:(Constructor<object>)[]
ScheduledConfiguration
Scheduled executor settings. These are settings for Executables that can be run as as a result of a schedule() call (Cloudflare Cron Job) or a DurableObject alarm() call.
extends ScheduledSettings
Members
concurrency?:numberThe number of Executables that can be run concurrently. Default is 1 (no concurrency).
executables:(Constructor<ScheduledExecutableInterface>)[]
VersionInfo
Build and deployment identity for a worker: its name and version plus the commit, build timestamp, and deployment metadata stamped by the build.
Members
builtAt?:stringcommit?:stringdeployedAt?:stringenvironment:stringid?:stringname:stringversion:string
WorkerBindingReference
A reference to a platform binding (R2 bucket, queue producer, KV namespace, service binding, etc.) by its binding name.
Members
binding:string
WorkerBindings
Platform-agnostic view of the bindings declared for the worker in its deployment configuration (e.g. Cloudflare's wrangler.toml).
CLI tooling adapts the raw platform configuration into this shape before handing it to module-contributed validators.
Members
d1Databases:readonly WorkerBindingReference[]kv:readonly WorkerBindingReference[]queues:readonly WorkerBindingReference[]r2Buckets:readonly WorkerBindingReference[]services:readonly WorkerBindingReference[]
WorkerConfigValidationContext
Context passed to a WorkerConfigValidator.
Contains everything a module needs to assert that its deployment configuration matches its runtime requirements.
Members
bindings:WorkerBindingsenvironment:stringenvironmentVariables:EnvironmentVariablessettings:BaseSettingsworkerName:string
WorkerQueueConfiguration
Settings related to queues for the Base Worker.
extends WorkerQueueSettings
Members
bindings?:string[]Queue bindings that the Base Worker will have access to. These are the queues that the Base Worker will produce messages to.
processors:(Constructor<WorkerQueueProcessorInterface<unknown>>)[]