DEV Community

Cover image for Implementing Microservice Architecture In Node JS

Implementing Microservice Architecture In Node JS

Lovepreet Singh on January 09, 2023

📍 Introduction 🙂 As we have discussed in our previous blog "Monolithic vs Microservices: A Practical Approach". But today we're going to...
Collapse
 
itsnitinn profile image
Nitin Sharma

Crisp and nice.

Collapse
 
brense profile image
Rense Bakker

Nice! I used node-http-proxy in the past to create a gateway, didn't realize that fast-gateway existed, it looks very clean 👍

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Thanks Rense. Highly appreciate 😊

Collapse
 
adnanafzal565 profile image
Adnan Afzal

You are using prefix as "/order" so I think your order server.js will have:

app.get("/order"

And not:

app.get("/order-list"

Kindly correct me if I am wrong.

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

You'll type localhost:9091/order and it will redirect you to the localhost:8081/

Collapse
 
pavanbelagatti profile image
Pavan Belagatti

When I call localhost:9091/order on my local, it I am getting 'page can’t be found' error. Am I doing something wrong?

Thread Thread
 
lovepreetsingh profile image
Lovepreet Singh

Start all the services including order payment and gateway

Collapse
 
murilokaos profile image
Murilo Henrique

Eu creio que não, ele vai ter as rotas com o /order como prefixo, ou seja:

/order e /order/order-list

Collapse
 
shifi profile image
Shifa Ur Rehman

True

Collapse
 
snowowl profile image
Snow Owl

This is very crisp and well done.

If you don't want to spend a lot of time doing config, we at Snow Owl have enabled request-level routing, monitoring, and transformations for microservices without using Kubernetes. This is done by creating a reverse proxy + API gateway + rules engine.

It's also SaaS, no-code, serverless, and sits on the edge. , we set up in 15 minutes and scale easily. DM me if you want to beta test! Snowowl.co

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Ok.

Collapse
 
victorioberra profile image
Victorio Berra

When will your site have docs, screenshots and info?

Collapse
 
snowowl profile image
Snow Owl

You can check out docs.snowowl.co for docs, screenshots, and video. Also if you drop your email in the homepage I'll send you an email with beta login!

Collapse
 
akcgjc007 profile image
anupam

what is the difference between let and const? 🤔

Collapse
 
rxavio profile image
xavier Rucahobatinya

const is a signal that the identifier won't be reassigned. let is a signal that the variable may be reassigned

Collapse
 
vaibhav68849256 profile image
Vaibhav Khandare

Helpful

Collapse
 
tlylt profile image
Liu Yongliang

Good demo! For simple routing/gateway it can also be done by setting up a reverse proxy with nginx.

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Already done in the previous blog

Collapse
 
410nidhi profile image
Nidhi Upasani

Great read

Collapse
 
arielro85 profile image
arielro85

Easy to Understand. Thanks for this

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Thanks 🙂

Collapse
 
latoadeoye profile image
latoadeoye

Highly appreciated. Your posit is motivational. Thanks

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Thanks man ☺😊

Collapse
 
restdbjones profile image
Jbee - codehooks.io

Very good intro.
Any thoughts on covering also a serverless node.js approach?

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Will do that in the next one... Thanks

Collapse
 
gulshanaggarwal profile image
Gulshan Aggarwal

Nice!

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Thanks Gulshan

Collapse
 
tahadostifam profile image
Taha. Dostifam

Would you suggest a directory structure for Microservice in Nodejs?

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

It is written in the blog

Collapse
 
pratikshirsath54 profile image
Pratik Shirsath

Easy to Understand. Looking forward to implement this. Can I have more details on this.

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Thanks. Will do soon 😃

Collapse
 
frankrsc profile image
Francisco Flores

can you do something like that but using docker?

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Sure, we can do that. Wait for more blogs in future, will do that

Collapse
 
frankrsc profile image
Francisco Flores

Nice! thanks, nice blog

Thread Thread
 
lovepreetsingh profile image
Lovepreet Singh

Thanks ☺

Collapse
 
nadavl profile image
Nadav Lebovitch

Nice, very neat.
Usually in a monorepo it's helpful to have a packages manager such as Turborepo or NX to install all the packages and dependencies.

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Noted Nadav. Thanks for your view

Collapse
 
rescenic profile image
Muhammad Ridwan Hakim

Thank you. Please continue for in-depth tutorials.

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Sure. No problem. Kindly share the content with your friends👭👬

Collapse
 
restdbjones profile image
Jbee - codehooks.io

Cool stuff!

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Thanks bruh

Collapse
 
muzzammil194 profile image
Muzzammil Shaikh

Nice content

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Thanks brother

Collapse
 
timhub profile image
Tech Tim (@TechTim42) • Edited
Collapse
 
maurer profile image
Daniel Maurer

Hello, what tool did you use to make the diagram?

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

I did make it in GoodNotes app in ipad

Collapse
 
hartajsinghdev profile image
Hartaj-Singh-Dev

great

Collapse
 
arpitpatel25 profile image
Arpit Patel

Nice and brief

Collapse
 
murilofranceschetto profile image
Murilo Gheller Franceschetto • Edited

Can anyone tell if this way is better than using nginx proxy with upstream and proxy_pass, if so why?

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

You can go with NGINX too, We did covered it in our previous blog

Collapse
 
light_seekern profile image
Taha Syed

Very well articulated

Collapse
 
dog1203 profile image
dog1203
Collapse
 
mohmmadaslam profile image
Mohmmad Aslam

Very insightful

Collapse
 
rihernandez profile image
Richard HC

Coul be interesting implement an authentication service to this architecture in order to understand how it works : api_gateway, auth_service, service1, service2.

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Ok, Richard Noted. Will do it in our next blog. Or maybe I will leave a reference to follow soon. Thanks for your time 🙂

Collapse
 
arjunbv777 profile image
Arjun

Better use nest js framework.. gives lot options for communicating with other services and for rest use express as it is in the nest.

Collapse
 
lovepreetsingh profile image
Lovepreet Singh

Will look into it. Thanks for pointing out buddy