Using Clean Architecture for Microservice APIs in Node.js with MongoDB and Express
In this approach I will demonstrate the use of Bob Martin's Clean Architecture model and I will show you how we can apply it to a Microservice built in node.js with MongoDB and Express JS.
- Node JS
- Mongo DB (To use the Mongo DB interface you need to install Mongo Compass, or have access to cloud.mongodb.com)
git clone
cd money-pal-api
npm i
Save sampledotenv
as .env
and then add your database details.
Usually this is Running in a cluster inside MongoDB Atlas provider. If you set up the .env file correctly you don't need to do nothing here.
To run in production mode where code is transpiled by Babel into a dist
folder and run directly in node
:
npm start
To run in development mode where code is run by babel-node via nodemon and re-transpiled any time there is a change:
npm run dev
To run tests:
npm run test
To run only e2e tests:
npm run test:e2e