Post/Code

HomeAboutUsesNow

Continuing Microservices.

Last week I started working towards building a basic microservice in Node.js. I have been following along with the Node.js Microservices for Beginners course on Udemy and I have enjoyed it thoroughly!

While the course is a little rough around the edges in terms of presentation, the content is interesting and engaging from multiple perspectives as it takes you through building the following:

  • A GraphQL server using Apollo. (Writing queries, mutations and resolvers)
  • A basic REST API with MongoDB (the course uses mLab but I used my own local MongoDB instance).
  • Managing your services with PM2. (And how to use the terminal to monitor your services)
  • Pushing messages to RabbitMQ hosted on CloudAMQP.
  • Sending email via Mailjet (Not yet watched and coded).

I have worked with GraphQL on this very website, but beyond the initial implementation of this site, I am not very familiar with this technology. This course has given me a good grounding and I am certainly keen to dig deeper on the topic in future!

REST APIs with Mongo is not new to me since I have been working with this stack for quite some time. However, it was great to see how to combine a Gateway GraphQL API in front, with a REST API behind it. This definitely opens up doors of possibility in decoupling the apps and services I build in future.

While the upcoming MailJet portion of the course will be interestring - what I am particularly excited about is the implementation of the queue! While I have implemented my own email sending service via Nodemailer using Handlebars for templating, I am really excited about using a queue to sit in between the mailing service and the API. Using the architecture and setup I am learning in this course will give me plenty of confidence to refactor such an implementation into a more modern and scalable setup.

Every now and then, you learn and do something in development which makes you feel like you are entering a new phase of ability - being able to implement and use a microservices with a queue/message based system definitely feels like a step in that direction for me.

Note: While the course uses CloudAMQP for the RabitMQ implementation and MailJet for sending emails, I will be looking to expand upon this by setting up my own RabbitMQ server as well as using NodeMailer to send the emails. Cloud services are fantastic! For production purposes they are the better option, however, for the process of learning and building that foundational knowledge, I feel it makes sense to do the work to set up one's own instance for the experience.