Skip to content

Instantly share code, notes, and snippets.

@carloswm85
Last active April 15, 2024 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carloswm85/88282e4569e6be32309ee04f864c57ee to your computer and use it in GitHub Desktop.
Save carloswm85/88282e4569e6be32309ee04f864c57ee to your computer and use it in GitHub Desktop.

CSE 341 - Web Services - Winter 2024

Best Links


w01 - Introducing our tech stack

Course Setup

Getting started with our first APIs

API Deployment at Render

  • What is API Deployment? A2 Hosting, Heroku, Amazon Web Services, DigitalOcean, Glitch, Google Cloud Platform, Microsoft Azure, Platform.sh, NodeChef, Render, Fly, Railway, Vercel, - Render
  • Render πŸ”—
    • Deploy a Node Express App πŸ”—
    • Environment variables and config vars Setup πŸ”—
    • Environment Variables and Secrets πŸ”—
  • Testing your deployed API

w02 - REST Clients, GET Requests, Node Architecture

Connect API to MongoDB Securely

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:

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


w03 - HTTP Requests & Dev Tools (and, Linters and Formatters)

URI Hierarchies

POST

As you learn about these different HTTP methods, know that there are always other ways to do things. For example, MongoDB uses queries and functions to insert, update, delete and retrieve data. Technically, I could use a POST to get data, modify it, or even delete it. However, these HTTP methods are here to add clarity and consistency to applications, and will work with other databases that don't rely on functions as much as MongoDB does.

PUT

DELETE

MongoDB CRUD

Here is a great article that sums up the CRUD (Create, Read, Update, Delete) process using Node.js and MongoDB.

Linters

Once you learn how to use code linters, you should never go back. When properly configured, they help keep your code, neat, clean, functional, and error-free. You should use a linter on your code for the remainder of this class.

Code Formatters

Once you learn how to use code formatters, you should never go back. When properly configured, they help keep your code neat, consistent and clean. You should use a formatter on your code for the remainder of this class.

More:

Project Configuration and Management

The following article shows how to set up a linter and formatter with your project. Ignore the React stuff this time around and be sure to select Node instead of Browser when it prompts for where your code will run.

Once this is all set up, you can run commands from the terminal like: "npm run lint" or the others that we put into the package.json.


w04 - API Documentation

API Documentation

Swagger

Other Options

  • Be aware that there are other resources for doing very similar types of API documentation. None of them appear to be as widely integrated with npm or as widely used in industry. Two other popular ones are Postman (which started off as just a rest client), and Readme. We will only use Swagger in this course.

Extra

  • Repo: davibaltar/example-swagger-autogen πŸ”—

w05 - REST & JSON Alternatives

JSON vs XML

REST Overview

RPC

XML+RPC

SOAP

GraphQL


w06 - Validation & Error Handling

Validation

Error Handling

Extra


w07 - OAuth

Explanation

Authentication Overview

OAuth Introduction

OAuth2 Vs OAuth1

Hands On

Getting Started with OAuth

Node.js API + OAuth + MongoDb

Extra

  • NodeJS & Express - Google OAuth2 using PassportJS πŸ”— πŸ“Ί ~20m
  • Lesson 7 Class Activity Walkthrough: Auth0 + Google πŸ”—
  • User model implementation:

w08 - OAuth

OAuth and Swagger

JSON Web Tokens (JWT)

JWT meets OAuth

Extra

  • Top 3 Things You Should Know About Webhooks! πŸ”—
  • Passportjs:

w09 - API Gateways and Managers

What Is An API Gateway?

As your API scales, you start to run into questions like "How can I control who makes requests to it and how many requests can they make? How can I make sure the interface with the frontend stays the same while the backend is being updated? How can I handle influxes of requests?" API management tools exist to help with questions like these. One of these tools is an API gateway. API gateways serve as a middle layer to go between your API and the clients that use it.

Popular API Gateways and Managers

An API Gateway acts as a middle layer between your API services and the clients that use them. Here are some popular solutions out there today:


w10 - API Gateways and Managers

Setting up an Azure Gateway

This is an example that would walk you through setting up an API manager through Microsoft Azure.


w11 - Testing

Why Testing?

JavaScript Testing Frameworks

Writing Unit Tests with Jest


w12 - Testing

Same content as Week 11.


w13 - Wrap Up

Resume Tips

Interview Prep

Here are some questions you should be prepared to answer for yourself:

  • How do I schedule a practice or mock interview with the BYUI career center?
  • What are the Wall Street Interviewing Strategies?
  • What is your market value?
  • How can you make a powerful introduction?
  • How should you dress for interviews or career fairs? What does your appearance say about you?

Interview Questions

Here are some questions you should be prepared to answer in an interview regarding the technologies taught in this class:

  1. T/F: NPM is a programming language.
  2. Node.js is a runtime for Javascript, NOT a Back End language.
  3. Node.js is a back end language, NOT a runtime for JavaScript.
  4. Node.JS allows JavaScript to be run outside of the browser.
  5. What does NPM stand for?
  6. What is the command to install the nodemon package globally?
  7. How do you initialize a Node.js project that creates a package.json and node_modules for you?
  8. What is the method to set up a server and make it run in a certain port?
  9. What Node.JS code is compiled into?
  10. What are Middleware functions?
  11. What is Express.js?
  12. What does MVC stand for?
  13. How do you make use of an express router for your requests?
  14. What is the responsibility of the Model?
  15. What is the responsibility of the Controller?
  16. How do you make relations in a NoSQL database such as MongoDB?
  17. What are the most important pieces of the structure of a MongoDB database?
  18. How do you find the id of a MongoDB document?
  19. What is a Cookie?
  20. What is a real disadvantage of using cookies on the client-side?
  21. What is a CSRF attack?
  22. The 300–399 range of http response status codes are for what?
  23. The 200–299 range of http response status codes are for what?
  24. The 400–499 range of http response status codes are for what?
  25. The 500–599 range of http response status codes are for what?
  26. What is the synchronous way of handling errors?
  27. What does the term β€œSanitizing” refer to in Node.js?
  28. Where exactly do you inject your dependencies?
  29. Is Node.js recommended for heavy calculations and 3D rendering?
  30. What is risk?
  31. What are the tasks of risk management?
  32. When identifying and classifying risks, what are the 5 main risk impact areas?
  33. Why isn’t it possible to pass images/files with the file picker through the body of the request?
  34. What do the skip( ) and limit( ) methods do and where do you use them?
  35. Which is the HTTP verb that should be used with client-side JavaScript in order to delete something upon request?
  36. T/F: When performing an asynchronous request, the server has to send a response without reloading/re-rendering the page.
  37. T/F: Because every company’s needs are unique, the payment process should not be outsourced and the development team should develop its own.

Resources


PROJECT IDEA: CMS (Content Management System)

  • A CMS software application allows users to create, manage, and publish digital content like articles, images, and videos.

Readings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment