peekinto
v0.0.5
Published
Express nodejs middleware that adds the ability to 'peek' into a request, perform processing but not be responsible for the output.
Downloads
3
Readme
Peek into a request
app.peek.get '/users/:name/**', (req, res) ->
res.locals.user = loaduser req.query.name
app.get '/users/:name/dashboard', (req, res) ->
res.locals.latestprojects = getlatestprojects res.locals.user
res.render '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