
This video will give you an overview about the course.
Explore the Node 12 new features.
See the rapid Node 12 installation with NVM.
• Install NVM
• Install Node 12
Learn the automated development project setup here.
• Plan the project architecture
• Create Bash script
• Run project setup script
In this video, see how to handle HTTP request to REST API.
• Create Express server instance
• Register Express middleware
• Register route handlers
Use ES6 modules and modularize Express project to separate business logic from API routes.
• Integrate ESM package to use ES6 modules
• Create Express router and controllers
• Register router to URL prefix
Implement integration testing with SuperTest/ debug and development scripts.
• Import Mocha/ SuperTest/ nodemon
• Create NPM scripts with ESM integration
• Run tests with Mocha
Deploy production-ready REST API to Heroku.
• Implement error handling with async wrapper
• Import PM2 and generate configuration and NPM start script
• Create a Procfile and push code to Heroku Cloud
Specify the endpoints of the contact API.
• Define resources served by the API
• Define the operations performed on the resources
• Set up boilerplate for Express server
Setup the routes and route handling logic to perform operations on contacts and groups.
• Setup the routers for contacts and groups
• Setup the route handlers
• Integrate routers with route handlers with error handling
Use Faker.js library to generate contacts.
• Define the model for the contact entity
• Create a map data structure
• Implement logic to generate contacts and store in map
Implement content negotiation with Express.
Version the EST API.
• Ensure the up versioning is necessary
• Create new routers with new functionality
• Use versioned URI path prefix
Integrate MongoDB to contacts API.
• Install MongoDB and MongoDB Compass
• Add MongoDB native driver for Node.js
• Implement logic to manipulate documents in collections
Connect to MongoDB Atlas Cloud services.
• Create a MongoDB account
• Create cluster on Cloud provider
• Connect to MongoDB Atlas
Implement database modeling with Mongoose.
• Create Mongoose schemas and models
• Implement connection logic using Mongoose
• Connect to MongoDB Atlas using Mongoose
Implement tests for Mongoose models.
• Create test file and NPM script using Mocha
• Create a test database
• Implement async test logic
Implement REST endpoints and HTTP status correctly.
• Define the specification of endpoints with media type and status codes
• User Express helper methods
• Test the API responses
Up version the API without breaking the current endpoints.
• Create an Express redirection router
• Use the 308-status code for permanent redirection
• Implement the new endpoints
Implement the hypermedia driven REST API architecture (HATEOAS).
• Create helper methods to the generated links for resources
• Decouple the controller layer from database layer using services
• Implement content negotiation generically
Set database to upload images for contacts.
• Drop your database
• Add dummy model to link uploaded file metadata to contact
• Implement GridFS in your database configuration
Set application logic to upload images for contacts.
• Generate contacts with the new model
• Modify the controllers and services to populate image field
• Implement upload logic
Set links for contacts with image.
• Refactor HATEOAS link generator to use URL instead of request object
• Implement logic to generate links
• Test the generated links for resources
Set pagination for Big Data handling.
• Add Mongoose paginate and express- paginate libraries
• Apply Mongoose paginate plugin to contact model
• Register express- paginate middleware and implement pagination logic
Set Redis database to cache data for contacts.
• Install Docker
• Run Redis server container
• Install Redis tools and run Redis-cli
Set application logic to cache data for contacts.
• Implement cache service class
• Connect to Redis cache server with driver
• Implement caching application logic
Restrict access to the API.
• Implement a CORS config class
• Implement a sync CORS config to set whitelist domains dynamically
• Add a CORS middleware to the chain of the request/response cycle for endpoints
Protect the API from Denial of Service (DoS) attacks.
• Implement a rate limit config class
• Point to the store where requests per IP will be counted
• Register the rate limiter config at the API level
Design the user model.
• Drop the contacts database
• Create a user schema and add an index to avoid duplicate users
• Create a user Mongoose model
Authenticate using JWT tokens.
• Make to run an LTS version of Node.js
• Create a password and a user auth service
• Create an authentication router and corresponding controller
Guard the API routes with Passport.js.
• Implement and register a Passport route protector middleware in the router
• Create an auth middleware to implement the JWT Passport strategy
• Register the auth middleware at the API level
Create contacts with logged users.
• Retrieve the logged user from the request object
• Implement CRUD service methods and controllers for contacts of logged users
• Implement CRUD endpoints for contacts of logged users
Create a web documentation of the API using the OpenAPI specifications.
• Import Swagger UI and SwaggerJsDoc libraries
• Create Swagger middleware and router
• Create OpenAPI compliant specification files to describe endpoints
Manage production-ready Node processes with PM2.
• Create ecosystem.config file for PM2
• Set the different environment variables in the ecosystem file
• Create NPM scripts to run PM2 in different environments
Transform the app into Docker microservices.
• Create a Docker Hub account
• Create a Dockerfile and build a Docker image
• Create a docker-compose.yml file
Manage our source with AWS CodeCommit Cloud service.
• Create an AWS account
• Create Git credentials in AWS IAM for your user
• Create a CodeCommit private repository
Create an AWS IAM role to be able to clone the code on our virtual machine in AWS EC2.
• Create an IAM role for the EC2 service
• Attach the permission policy to read-only CodeCommit
• Name the IAM role with a descriptive name
Setup the AWS ECZ virtual machine to run the microservices.
• Create a new EC2 instance with security group and key pair
• SSH into the EC2 virtual machine
• Install system dependencies (NVM, Docker, Docker-compose)
Launch the microservices on the EC2 virtual machines.
• Clone the app repo in the VM and install Node and project dependencies
• Whitelist the public IP of the EC2 VM in Mongo Atlas
• Launch microservices with Docker Compose
Create the web application server.
• Create client folder
• Import dependencies
• Implement basic view
Handle errors by displaying an error page.
• Implement error EJS include
• Add error EJS to include two main EJS template with conditional rendering
• Implement custom Express error handler middleware to render error page
Allow web users to create an account to log in.
• Implement signing and signup EJS include
• Implement web server endpoints to handle form submission
• Implement endpoint for post signing redirection with token
Show the contacts of the logged user.
• Implement contacts table EJS include
• Make request to get contacts on backend
• Set EJS template variables to display contacts when logged in
Add contacts to the logged user.
• Implement the add contact form EJS include
• Implement the endpoint to push contact creation data to back end
• Redirect to the main page with updated contacts table
Deploy the client Web app microservice to the Docker Compose stack on AWS
• Create Dockerfile in client folder and build and push Docker image
• Update Docker Compose YAML configuration file
• Push code to AWS CodeCommit, pull in EC2, and restart Docker Compose
Summarize the course.
RESTful web APIs allow developers to create unique applications by leveraging the data on the internet. If you want to build fast-paced REST APIs and deliver large amounts of data to many users, you'll find this course essential.
In this course, you will learn to create scalable and rich RESTful applications based on the latest Node.js platform. You will learn to customize your RESTful development process using the latest NPM and understand the key principles to convert an HTTP application into RESTful-enabled applications. You will then create and test Node.js modules with automated tests, use MongoDB to store data, and get to grips with using self-descriptive URLs.
You will also use OpenAPI (Swagger) to document the API and Mocha to implement automation tests for a REST-enabled endpoint. We will explore authentication techniques to secure your application.Lastly, we will take advantage of Amazon Web Services (AWS) to deploy our APIs as microservices using Docker.
By the end of this course, you will have a solid grasp of APIs, HTTP, REST, authentication using tokens, API testing, site reliability, performance, security, and integration with cloud services.
Please note that familiarity with Node.js and Express.js (or similar), together with an understanding of Docker and CI/CD, is assumed for taking this course.
About the Author
Florian Goto specializes in architecting and building web solutions with TypeScript, JavaScript, and Node.js on front end, back end, mobile, and serverless/cloud-native platforms. He stays well informed about open source web technologies, particularly in the JavaScript and Node.js multiverse.