EventsRouter
EventsRouter
Router for discovering and managing event handler files in a directory structure. Events are represented by directories, and handlers are files within those directories.
Signature
class EventsRouter {
constructor(options: EventsRouterOptions)
addEntrypoints(entrypoints: string[]) => ;
match(event: string) => ParsedEvent | null;
entrypoints: string[]
isValidPath() => ;
clear() => ;
populate(events: EventsTree) => ;
reload() => ;
scan() => Promise<EventsTree>;
scanIncremental(changedPath: string, _changeType: EventsRouterFileChangeType = 'change') => Promise<EventsTree>;
toJSON() => EventsTree;
}
constructor
method
(options: EventsRouterOptions) => EventsRouterCreates a new EventsRouter instance
addEntrypoints
method
(entrypoints: string[]) => Adds new entrypoints to the router
match
method
(event: string) => ParsedEvent | nullFind a parsed event by its name
entrypoints
property
string[]Get the entrypoint directory path
isValidPath
method
() => Checks if the entrypoint path is valid
clear
method
() => Clear all parsed events
populate
method
(events: EventsTree) => Populates router state from pre-resolved event metadata.
reload
method
() => Reload and re-scan the entrypoint directory for events
scan
method
() => Promise<EventsTree>Scan the entrypoint directory for events and their handlers
scanIncremental
method
(changedPath: string, _changeType: EventsRouterFileChangeType = 'change') => Promise<EventsTree>Incrementally rescans only the event subtree impacted by a changed path.
toJSON
method
() => EventsTreeConvert the internal events Collection to a plain object