Express.js is arguably the most popular web framework for Node.js
A typical app structure for express celebrates the notion of
handlers, while views and data are left for interpretation (probably because the rise of microservices and client-side apps).
So an app structure may look like this:
routes.js glues everything together:
Unlike React Native, you could dynamically load modules here. However, there's still a need for judgement when constructing the routes (
hygen let's see how we could build something like this:
So let's say our generator is structured like this:
inject_handler looks like this:
Note how we're anchoring this inject to
before: "module.exports = app". If in previous occasions we appended content to a given line, we're now prepending it.