clay / amphora

Middleware for Express that composes components into renderable pages
https://claycms.gitbooks.io/amphora/
MIT License
31 stars 23 forks source link

Adds middleware to the same Layer as the renderer #680

Closed felkerch closed 4 years ago

felkerch commented 4 years ago

Amphora currently attaches route-specific middleware by adding two Layers to the router: one for the middleware and then one for the renderer. This PR adds them to the same layer. Basically this is the diff:

- router.use(path, middleware);
- router.get(path, renderer);
+ router.get(path, [middleware, renderer]);

You'll see different behavior if your middleware makes changes to the request (we change the URL for pagination).

The interface for adding routes to a site remains the same:

module.exports.routes = [
    { path: "/:name", middleware: [fn] },
    ...
]
coveralls commented 4 years ago

Pull Request Test Coverage Report for Build 2428


Totals Coverage Status
Change from base Build 2426: 0.0%
Covered Lines: 4178
Relevant Lines: 4178

💛 - Coveralls