Peek into a request
apppeekget '/users/:name/**' res.locals.user = loaduser reqqueryname appget '/users/:name/dashboard' res.locals.latestprojects = getlatestprojects reslocalsuser resrender 'dashboard'
What is the problem?
A web request can be thought of as a pipeline. To render a given request multiple modules may have contributed to the content. The output of each module may be a rendered template or the results of an intermediate query. To finish off all the content and values are collected and rendered into the destination template.
How peekinto solves this problem
- Peekinto adds an additional structure to the express application object called peek. This has the same verb registration methods - get, post, put, delete.
- Methods registered against these verbs are not expected to complete the request.
- Multiple methods can match the same request, each getting an opportunity to perform processing.
- After all peek methods are run the normal app.VERB methods are called.
Goals
- Simple
- Work with existing code
- Support UI composition