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.
new EventsRouter(options)
Parameter | Type | Optional | Description |
---|---|---|---|
options | EventsRouterOptions | ❌ | Configuration options for the router |
Properties
public entrypoints: any
Get the entrypoint directory path
Methods
public addEntrypoints(entrypoints): void
Adds new entrypoints to the router
Parameter | Type | Optional | Description |
---|---|---|---|
entrypoints | Array<string> | ❌ | Array of new entrypoint paths |
public clear(): void
Clear all parsed events
public isValidPath(): boolean
Checks if the entrypoint path is valid
public match(event): null | ParsedEvent
Find a parsed event by its name
Parameter | Type | Optional | Description |
---|---|---|---|
event | string | ❌ | Name of the event to find |
public reload(): Promise<EventsTree>
Reload and re-scan the entrypoint directory for events
public scan(): Promise<EventsTree>
Scan the entrypoint directory for events and their handlers
public toJSON(): EventsTree
Convert the internal events Collection to a plain object