The Server Side Of Things - Part 1

The Server Side Of Things - Part 1

This is Part 1 of an introductory series to building server side applications with Nodejs.

Efosa Jeffrey's photo
Efosa Jeffrey
·Apr 11, 2022·

5 min read

Table of contents

  • What is an HTTP request?
  • What happens next ? (The Server Side Of Things)
  • Conclusion
  • What's next?

Ever wondered what happened behind those clicks you make or forms you submit when browsing through the web? Or if you are coming to the Front-end side of things, what happens behind those HTTP requests you make to that API endpoint?

Follow through this article, you'll get it by the end 😁

This article is part of an introductory series to building server side applications with Nodejs. Nodejs is a technology that gives you the ability to build server side applications with JavaScript programming language. We'll talk more about Nodejs later.

Let us begin by talking a little about HTTP requests.

What is an HTTP request?

Firstly, HTTP stands for Hypertext Transfer Protocol. This protocol is the standard used for web-server communication on the internet.

Have you ever thought about what happens when you type https://twitter.com URL in your favourite web browser or when you open the twitter app on your mobile phone? The Client (your web browser or mobile application) makes an HTTP request to Twitter's server to get the latest tweets. In web server communication language it makes a GET request to Twitter's server to retrieve the latest tweets.

Another scenario or an HTTP request. If you like tweeting or writing (like me 😊), the moment you are done writing and click on "tweet" or "publish", the Client sends out a HTTP POST request to a backend server that makes an attempt to save your tweet or post to a persistent storage (database) so your audience can retrieve your tweet or post from their devices.

Both examples are common operations that go on each second, minute and everyday.

GET and POST are referred to as HTTP methods. These methods amongst others determines the action being performed by the client. GET indicates retrieving data from server, while POST indicating data being sent to the server. A GET could also be used to send some data to a server, e.g when you click on a user icon to access their profile on Twitter, you are sending out a GET request with the associated username to retrieve information about that user. A POST method is used when submitting form data. Other methods are PUT (for updating data on the server), DELETE (for deleting data).

When using your favourite browser, the moment you type in a URL, by default you are making a GET request to a particular server location designated by the domain name.

Domain name, often referred to as “web address”, is the address that people type into a browser address bar to find your website. A registered domain name is unique to you and can’t be used by anyone else, as it functions on the Internet in a similar way like a street address in the physical world. Read more.

When you submit a form, from your browser, by default, you are making a POST request to a web server. The only difference as a frontend developing using an API client (e.g Postman) is that you specify the method you are using before sending out the HTTP request.

If you've gotten here, you deserve some accolades 😁 The Rock applauding

What happens next ? (The Server Side Of Things)

Before we continue, let us define what a server or web server is.

A server could be a hardware or software running on another computer, that has the ability to receive requests (actions to perform) from a Client and respond to such requests (perform the intended action and return a result whether successful or failed). In computing this architecture is normally referred to as the client-server model. There are different types of servers including but not limited to:

  • Database servers
  • File servers
  • Mail servers
  • Game servers
  • Web servers, etc. (Know more)

We are more concerned with a Web server for now.

A web server is computer software and underlying hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initiates communication by making a request for a web page or other resource using HTTP, and the server responds with the content of that resource or an error message. - Wiki

Back to what happens when an HTTP request gets to a web server.

When you send out a request to a web server using a URL e.g https://some-domain.com/users usually called an endpoint, the request goes out through the network (internet) and gets to the computer where the web server is running on. Usually, each request made to a web server normally has meta information added to it. The meta information (normally attached to what's called an HTTP request header) includes important details about the request that makes the web server know exactly what the Client wants to do.

It's more like explaining yourself properly when placing your order in your favourite restaurant, so you get exactly what you ordered for.

The web server is a software like we have seen. And that software was created with a technology written with a programming language like Javascript, Python, Java, PHP, etc.

The technology used to create the software has a feature that can be used to parse the request (to get the meta data sent by the client) and then know what action to perform. The web server has the ability to connect to other servers (e.g database), or make requests to another web server in order to get a desired resource and send back the data to the client based on request.

Examples of common requests sent to the web server includes:

  • Request to get the static files (images, fonts, javascript, css) that make up a web page
  • Request to get the some data (e.g tweets, blog posts), that make up a web page
  • Request to log in a user in order to have permissions to access various resources, etc.

Conclusion

This is a concise introduction to what happens "behind the scenes" of a web application. We took a look at what an HTTP request is, what a server and web server is and what happens when an HTTP request gets to a web server. We will look at more details in the part 2 of this article series on building server side applications using Nodejs.

What's next?

Stay tuned for the next article. Don't forget to give a thumbs up, follow and share 🎉 Thanks for reading 🤗

 
Share this