javascript - Is using compose to add routes and middleware to an Express app an anti-pattern? -
i working on small server used boilerplate future servers. since order can matter middleware, reached compose pipe them in obvious order. goal add 1 level of abstraction middleware , routes can swapped out later without many changes entry point.
given info, seem anti-pattern use compose
since middleware/routes impure , modify (app)
gets passed in?
'use strict'; import { createserver } 'http'; import express 'express'; import { flowright compose } 'lodash'; import { system, environment } './config'; import routes './routes'; const setup = compose(routes, system); const app = setup(express()); createserver(app) .listen(environment.port, environment.ip, () => { console.log('server running!'); });
Comments
Post a Comment