CSE 341: Web Services

W01 Learning Activity: Web Services and Node Architecture

Overview

This learning activity assumes you have set up and installed all the tools for the course. If you have not, return to the Tools Setup page and follow the steps or reach out to your teacher or classmates before proceeding.

Now that you have all the tools in place, you will learn how to set up a Node.js server and then to organize your Node.js code to create web services more efficiently. You will also learn how to use REST clients to effectively test your services when there isn't a frontend available to consume them. Lastly, you will create a number of HTTP GET requests that will push you to learn more about how HTTP requests work in general.

Topics for this lesson:

Learning Material

Learning Material Expectations

Each week contains learning activities that provide learning material that you will use throughout that week, and for the rest of the course.

The learning material in this course is different than in many other courses and this is by design. In earlier courses in the program, you are given very clear directions on exactly what to read and the steps to perform. As you are maturing in your study of Web development, it is important for you to be able to read and understand content directly from the Web. In a few years, the specific technologies discussed in this course may become outdated, but the principles you are learning and most importantly, your ability to learn new things from content on the Web, will be something you will continue to use throughout your career.

With this in mind, for each of the concepts in each lesson, you will be given links to a few documents on the Web. We have chosen these documents because they do a good job explaining the concept, but you may want to find additional sources on your own, by searching the internet for more information.

Question: How much of the information do you need to read?

Answer: You should read enough to become familiar with all of the concepts listed, and to be able refer back to these or other sources for more information as you start implementing the concept.

In some cases, you may be very familiar with a concept, so a light skimming of the material is enough to refresh it for you. In other cases, you may need to read every word and work through the examples provided. And in others, you may need to find even more sources. It all depends on your understanding.

Resources for this lesson are accessible to you in this repository

Getting started with our first APIs

Become familiar with the following topics:

Building the API with Node.js

Getting started with Node.js

This course is an API development course. An API is defined as an application programming interface, or a connection between computers or between computer programs. In web development, APIs or Web Services allow us to request data from a server (in our case, a Node.js project), which will then get data from a database and send back to the frontend whatever data they requested. This is what APIs and Web Services do.

We will build robust, secure backends that will work with websites, mobile apps, wearable apps, and many other things. We will create data endpoints that will simply deliver data to any frontend when requested.

This entire course will use Node.js, which will require you to be very familiar with JavaScript. If you feel you may need a JavaScript refresher before beginning, the following video is a good one. From there, feel free to search Google or YouTube for individual concepts that still aren't clear.

There are many different tech stacks and languages that can handle API development in the way that we are going to do. Some popular ones include Node, C#, Java, Ruby, and Python. More important than learning any one of these is learning how to create web backends. Once you've learned one, the rest will come with relative ease.

In this course, we will use Node.js as our backend technology of choice. To prepare you for your assignment this week, here are some helpful resources to start learning Node:

Saving to GitHub

All information and videos about saving to GitHub for this class can be found on the GitHub page.

Publishing to Render

All information and videos about publishing an API to Render for this class can be found on the deployment page.

At this point in the lesson, you may be feeling a little lost, confused, stressed, frustrated, or worried. Please remember, that this course is designed to help teach you how to find answers and information independently. With that said, there are solutions provided for the first two weeks. In addition, here is one more video for this lesson to help you learn a bit about node.

The following video may be helpful but is not required.

Connecting to APIs

Become familiar with the following topics:

Connect API to MongoDB Securely

REMEMBER: You will never push sensitive information to GitHub. Your MongoDB connection string should be stored in an .env file. This .env file should be listed in your .gitignore file so that it never gets included in your commits.

REST Clients

A REST client is a tool that allows us to invoke a REST service API. In lesson 1, we created our first GET request API and we actually ended up seeing that data directly in the browser. To an extent, our browser functioned as our REST client last week. However, there are many things that our browsers cannot do without some client-side code. For example, if I needed to make a GET request with any type of dynamic data, headers, authentication keys, or other similar pieces of data, I would not be able to unless I had a frontend project in place. REST clients on the other hand, will allow us to make all sorts of HTTP requests with all sorts of data in an environment that is intuitive and convenient.

The number of REST clients in production today is very great, with these programs coming and going like much of the software we see on a regular basis. Here are several REST clients being used widely in industry today:

You can read about many others in this Google search.

GET Requests

There are a lot of different ways to learn about GET requests, and you're likely already familiar with what they are from previous classes you've taken. For example, in WDD 230, you made several fetch requests (JavaScript client way of sending http requests to a server), to get temple data, or weather data...those were GET requests. Here are some resources below to learn more about these, and also to learn how to make them in Node.

Query Parameters
Debugging Node
Headers
Node Architecture and API Organization

Other Links: