Fake Mirrors
    Preparing search index...

    Class ReplServerRouter

    Represents the repl-server router.

    Depends:

    import { DIContainer } from '@famir/common'
    import { ReplServerRouter } from '@famir/repl-server'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Register in DI container
    ReplServerRouter.register(container)
    import { DIContainer } from '@famir/common'
    import { REPL_SERVER_ROUTER, type ReplServerRouter } from '@famir/repl-server'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Resolve from DI container
    const router = container.resolve<ReplServerRouter>(REPL_SERVER_ROUTER)

    interface SimpleArgs {
    _: string[]
    }

    // Add custom command
    router.addCommand<EchoArgs>(
    {
    name: 'echo',
    description: `Simple echo command`,
    schemaName: 'echo-args',
    options: [],
    params: [],
    },
    async (console, spec, args) => {
    console.log(args)
    }
    )

    // Activate router
    router.activate()
    • Activates the router.

      Once activated, commands can be retrieved but not added.

      Returns void

    • Retrieves a command for a specific name.

      Commands can only be retrieved after the router is activated.

      Parameters

      • commandName: string

        The name of the command.

      Returns ReplServerCommand<ReplServerCommandArgs> | undefined

      The command object, or undefined if not found.

      Error If the router is not active.

    • Returns string[]

    • Returns Record<string, string>

    • Registers the router as a singleton in the DI container.

      Parameters

      • container: DIContainer

        The DI container to register in.

      Returns void