Skip to main content
Version: Next

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() => ;
reload() => ;
scan() => Promise<EventsTree>;
toJSON() => EventsTree;
}

constructor

method
(options: EventsRouterOptions) => EventsRouter

Creates a new EventsRouter instance

addEntrypoints

method
(entrypoints: string[]) =>

Adds new entrypoints to the router

match

method
(event: string) => ParsedEvent | null

Find 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

reload

method
() =>

Reload and re-scan the entrypoint directory for events

scan

method
() => Promise<EventsTree>

Scan the entrypoint directory for events and their handlers

toJSON

method

Convert the internal events Collection to a plain object