Our core business logic needs to be accessed in some way, and I think a RESTful API would serve us in a good way. In order to get a better understanding and move through the whole app, we are only going to showcase a few parts from our API.
We are more interested in the whole app from an architectural point of view, instead of having detailed and fully integrated functionalities.
For this micro app, we are going to group our files by type context. First, we are going to create our micro app class, apps/api/index.js
, and add the following content:
'use strict'; const ProductsRoutes = require('./routes/products'); const ProductController = require('./controllers/product'); class Api { constructor(config, core, app) { let productController = new ProductController(core); let productRoutes = new ProductsRoutes(core, productController); this.config = config; this.core = core; this.app = app; this.root = app.get('root'); this.rootUrl =...