APIs and Microservices

β€” 9 minute read

This is a post about my experience of completing the Free Code Camp Certification - APIs and Microservices β†—.

There are also a group of posts on this blog about my experience completing the Free Code Camp Intermediate Algorithm Scripting β†— in Javascript certificate too. Those posts can be found here.

My certificate πŸ‘¨β€πŸŽ“πŸ±β€πŸπŸ‘‡

Zachary Parsons - APIs and Microservices Certificate from Free Code Camp

According to the Free Code Camp website this certification is about 300 hours of work. There are 4 sections which need to be completed to earn the Free Code Camp APIs and Microservices certification. These sections are:

As you can see the fourth section is the part which takes up the majority of the 300 hours. This is self-directed learning. There is no hand holding. Well not much - but more about that later. Below is a quick run through of my experience of completing each of the sections.

Each section involves using a 🎏Glitch β†— project, each have varying degrees of starter code within them, but which allow you to focus on the subject being taught at that moment.

Managing Packages with Npm permalink

Does anyone else always write 'nom' instead of 'npm', or is it only me!? πŸ₯ž

This section is an introduction to the 'package.json' file. This is a file which all node projects include.

If you don't know already NPM stands for Node Package Manager, and that's exactly what it is. It is a system which makes it easier to access Node packages (you can think of packages as groups of related code modules 'packaged' together, and then made easily accessible to other users for their projects).

This Stack Overflow answer β†— sums it up quite well:

Shapes             <- Package name
- Circle.js <-
- Rectangle.js <- Modules that belong to the Shapes package
- Square.js <-

The package.json file provides project-level control over which packages are being used and how. This section of the certification is fairly straightforward - there is no problem-solving to be done - but it is a great introduction into how a node project works.

Basic Node and Express permalink

This section mainly focuses on Express. Express is a web application framework for Node - more on this in a minute.

First, Node. Node β†— is a JavaScript run time environment. This means that by using Node it is possible to write server-side scripts (rather than just client-side, which you can do with regular vanilla β†— flavoured JS).

Really what this means is you can run JavaScript outside of a web browser. Prior to Node a web application needed a programming language for server-side scripts (which may have been Python, PHP, or Ruby for example, but which couldn't be JavaScript), and then JavaScript could be used for client-side scripts to provide additional functionality after the web application had already been served to the user.

Next, Express. Express β†— is a web application framework for Node. It's equivalent to Django in Python, or Laravel in PHP. These are essentially sets of pre-written code (in each respective language) which help to reduce complexity for developers while they are creating web apps. In other words web frameworks like express are a form of abstraction β†— for every day developers.

I found it interesting to compare framework tag lines while writing this post:

Django: The Web Framework for Perfectionists with Deadlines Django β†—

Laravel: The PHP Framework for Web Artisans Laravel β†—

Express: Fast, unopinionated, minimalist web framework for Node.js Express β†—

'Unopinionated'... What does it mean for a web framework to be unopinionated? Good question. What this means is that Express does not mind how you complete your task - or put differently there are multiple ways to complete the same task and Express will allow them.

In contrast an opinionated web framework will often expect a particular task to be done in a particular way - and might make it more difficult to be done in a different way. Often this is because, in a specific domain, it makes much more sense to be done in this way. So 'opionated' does not equal restrictive or worse usually, just a tool for a specific job.

There is some more information on the MDN Node / Express tutorial page β†—, along with another great introduction to Node and Express.

The FreeCodeCamp tutorials focus on Express - which is great because a working knowledge of Express is enough to begin building web applications and (simple) APIs. The lessons covered include starting an express server, serving static files, creating routes, get parameter inputs from routes and queries, and parsing data sent via POST requests.

MongoDb and Mongoose permalink

In order to create an API, or a Microservice, which is truly useful you will need some form of storage, and a relatively straightforward way to access that storage. MongoDB is the former, and Mongoose the latter.

Even if the API is very simple, it could still be useful. For example a Cat image API would be useful to someone who wants cat photos on demand 🐱 β†—...

MongoDB is a 'NoSQL' β†— storage system, or database. And Mongoose β†— is 'object modelling' for Mongo - it makes it easier to model the data you have into a human readable format, in this case into objects. Mongo and Mongoose are popular amongst JavaScript devs because of their use of JSON as a document storage structure - so as the fcc tutorial says:

Accessing documents and their properties is like accessing objects in JavaScript. Mongoose.js is an npm module for Node.js that allows you to write objects for Mongo as you would in JavaScript. This can make it easier to construct documents for storage in Mongo. From here β†—

// Example of a possible 'document' in a MongoDB ->
"name": "image-example.jpg",
"type": "image/jpeg",
"size": 25467

This section provides a good overview of them both, and runs you through some challenges which include writing code that follows best practices of using Mongo with Mongoose for web app storage.

The Projects permalink

For each the starter code is provided on Glitch, but honestly this is only to ensure while completing the challenge you don't get overwhelmed or held back by the details of implementation such as correctly configuring express.js, other dependencies and packages, and the design and aesthetics (all of which are important - but they quickly pile up and become too much to focus on for a learner).

My submission for each of the projects is embedded below - I won't go into detail about each one because this is already a long post. Some of these are more challenging than others - the exercise tracker probably has the most functionality attached to it, as well as needing the most complex database. They are all doable - all you need is to put in some time, research the right sites (some helpful links below), ask questions β†—, and don't give up!

If you read this and want to ask me specifics about any of the projects (or anything else) - send me a tweet πŸ‘‹ β†—, as that's where I'm most likely to be, and follow me there too!

Helpful Links - Projects Below ⬇

MongoDB Docs β†— Mongoose Docs β†— Full Node & Express Tutorial - Mozilla β†— FCC Forum - Topic about Exercise Tracker Project β†— FCC Forum - Curriculum Help & Certification Projects β†— Stack Overflow β†— Google πŸ˜… β†—

Timestamp Microservice permalink

z-timestamp.glitch.me β†— - Link to project (embedded project below)

Request Header Parser permalink

z-header-parse.glitch.me β†— - Link to project (embedded project below)

URL Shortener Microservice permalink

z-link.glitch.me β†— - Link to project (embedded project below)

Exercise Tracker permalink

z-exercise.glitch.me β†— - Link to project (embedded project below)

File Metadata Microservice permalink

z-file-metadata.glitch.me β†— - Link to project (embedded project below)

If you made it all the way down here - thanks for reading! Tell me what you think... β†— and here's some cake: 🍰