Exposing an API

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.

The Api class

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 ...

Get MEAN Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.