Optionaloptions: CreateRuntimeServicesOptions
Platform override and adapter injection
Runtime services for the resolved platform
import { createRuntimeServices } from '@setu-ts/runtime';
import { loadConfig } from '@setu-ts/config-plugin';
const config = await loadConfig(createRuntimeServices());
const url = config.getOrThrow<string>('DATABASE_URL');
Creates runtime services for the current platform.
Use this when runtime services are needed before an application is constructed — reading environment variables to build configuration, for example. Inside an application, resolve
CAPABILITIES.RUNTIMEfrom the service registry instead:RuntimePluginregisters the instance it builds through this same function.The returned services are a stateless facade over platform globals, so building a second instance alongside the application's own is safe: they hold no connection, no cache, and no handle registry, and nothing compares them by identity.
One caveat worth knowing rather than discovering:
envis a snapshot taken at construction, not a live view. Two instances built at different moments observe the environment as it was at each of those moments, so a variable set in between is visible only to the later one.On Cloudflare Workers there is no ambient environment to snapshot, so
envstays empty unlessCreateRuntimeServicesOptions.envis supplied.