CommandsRouter
CommandsRouter
CommandsRouter handles the discovery and routing of commands and middleware files in a directory structure. It supports nested commands and middleware inheritance.
new CommandsRouter(options)
Parameter | Type | Optional | Description |
---|---|---|---|
options | CommandsRouterOptions | ❌ | Configuration options for the router |
Properties
public entrypoint: any
Gets the configured entrypoint directory
public matchers: any
Gets the configured matchers for command and middleware files
Methods
public clear(): void
Clears the internal commands and middleware maps
public getData(): {
commands | : Map<string | ParsedCommand>; middleware | : Map<string | ParsedMiddleware>; } Returns the cached data of the commands and middleware
public isValidPath(): boolean
Checks if the entrypoint path is valid
public match(commandOrSegment): null | CommandMatchResult
Matches a command by name or path segments
Parameter | Type | Optional | Description |
---|---|---|---|
commandOrSegment | string | Array<string> | ❌ |
public reload(): Promise<CommandsTree>
Reloads the commands tree by re-scanning the entrypoint directory
public scan(): Promise<CommandsTree>
Scans the entrypoint directory for commands and middleware
public toJSON(): CommandsTree
Converts the internal maps to a serializable object