Node.js + Express

Express is the first web framework I am learning. Back when I used to create Joomla and Wordpress websites, I always wondered how back-ends worked. I was always curious about the various plugins available at my disposal but having no idea about how they worked under the hood.

Now that I am tackling back-end engineering, it feels great that some long-lasting mysteries are starting to be solved.

Basic Routing

When clients make requests to an application, the app’s server responds. Requests are made to the server using an application’s endpoint (URI) and a HTTP method (GET, PUT, POST, etc.).

A route definition looks something like this:


Usually, app is the variable in which express(); method is invoked to create a server. METHOD is an HTTP request method. PATH is a path on the server that the user wants to perform the HTTP action on (get, put, post, delete, etc.) and finally, the HANDLER, which is a function that is executed once the path is matched.

Basic Routing Example

var express = require(‘express’);
var app = express();
// An action by the server will be taken.
app.get('/', function(req, res) {
  res.send("Hello World!");

Here, app.get is the ‘app.METHOD’ portion of our code, mentioned above. In this case, we are using the GET method. As specified in Wikipedia,

GET requests a representation of the specified resource. Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications. One reason for this is that GET may be used arbitrarily by robots or crawlers, which should not need to consider the side effects that a request should cause.

More to follow…


Uniform Resource Identifier — This means that

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.