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.

new EventsRouter(options)
ParameterTypeOptionalDescription
optionsEventsRouterOptionsConfiguration options for the router

Properties

public entrypoint: any

Get the entrypoint directory path

Methods

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

ParameterTypeOptionalDescription
eventstringName 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 map to a plain object