Stratal API Reference
    Preparing search index...

    Class Application

    Application

    Main application class managing the two-tier container hierarchy:

    • Global Container: All services (singletons via tsyringe native)
    • Request Container: Child of global, context-enriched instances per request

    Architecture:

    Container (manages global container internally)

    All services registered via container.register()
    (auto-detects scope from decorators)

    Request Container (child, per request)

    Context-enriched instances via
    container.runInRequestScope() or container.createRequestScope()
    const app = new Application(env, ctx, config)
    await app.initialize()

    // Access container via getter
    const service = app.container.resolve(MY_TOKEN)

    // Handle HTTP request (via RouterService middleware)
    // Handle queue batch
    await app.handleQueue(batch, 'my-queue')
    Index

    Constructors

    Properties

    ctx: ExecutionContext

    Accessors

    • get container(): Container

      Get the Container instance

      Use for service registration and resolution:

      • app.container.register(ServiceClass)
      • app.container.resolve(TOKEN)
      • app.container.runInRequestScope(ctx, callback)

      Returns Container

    Methods

    • Create mock RouterContext for queue/cron/seeder processing

      Use this when you need to create a request scope outside of HTTP context.

      Parameters

      • locale: string = 'en'

        Locale for i18n (default: 'en')

      Returns RouterContext

      Mock RouterContext suitable for runInRequestScope

    • Handle queue batch processing

      Creates a request scope with mock RouterContext and processes the batch. Queue name is passed for logging purposes; routing is by message type.

      Parameters

      • batch: MessageBatch
      • queueName: string

      Returns Promise<void>

    • Handle scheduled cron trigger

      Parameters

      • controller: ScheduledController

      Returns Promise<void>

    • Resolve a service from the container

      Type Parameters

      • T

      Parameters

      • token: symbol

        DI token for the service

      Returns T

      Resolved service instance