americano
americano copied to clipboard
Real hook system
Currently we have two hooks: beforeStart and afterStart. In my experience, it's not enough. I mean I never get what the hook I want where I want. Sometimes I need it before plugins are loaded, sometimes right after, .... so I end up not using beforeStart and afterStart (or rarely).
I suggest we turn americano
(the object) into an event emitter that triggers events at each step of initialization:
- before anything happens
- before configuration loads
- after configuration loads
- before plugins are loaded
- after each plugins has been loaded (with the plugin name)
- after plugins are loaded
- before routes are loaded
- after routes are loaded
- before http server actually starts
- after http server actually starts
- after everything happens
Many events are redundant here but this adds semantic. The callback for these events could be declared in an ./server/init.coffee file or in the configuration (if we feel the configuration events are not relevant).
Good idea :+1: !