Setu-TS
    Preparing search index...

    Function createRuntimeServices

    • 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.RUNTIME from the service registry instead: RuntimePlugin registers 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: env is 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 env stays empty unless CreateRuntimeServicesOptions.env is supplied.

      Parameters

      Returns IRuntimeServices

      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');
      import { env } from 'cloudflare:workers';
      import { createRuntimeServices } from '@setu-ts/runtime';

      const config = await loadConfig(createRuntimeServices({ env }));

      If no factory is registered for the resolved platform

      0.2.0