By David Armendariz, Software Engineer
Introduction to Sequelize ORM (w/ Express.js + Postgres)
Course description
Hi and welcome to this course! Here, you will learn A LOT about how to build a simple backend with production-level code. We are going to learn how to set up a local database with Docker, how to use Express.js with Sequelize as the ORM and manipulate the database, how to test our code with Jest and more importantly, how to structure our code to test it easily. We will also learn: Sequelize best practices (how to register models, how to register associations between models, how to add scopes, how to make simple queries, how to write migrations, etc.) JWT and Bcrypt to handle authentication and Testing with Jest (remember that untested code is broken code) Express middlewares and how to test them Docker and Docker Compose to set up a local database and avoid installing databases locally Best practices in general (separating the Express app from the server for easier testing, separating model logic from the controller, hiding passwords from the response, etc.) This course is different as I am looking for you to learn how production-level code looks like and build the habit to test every line of code you write! Most courses skip testing, but the reality is that testing is so important on software development that it is unbelievable that most courses out there just skip them.
Related Skills
Course overview - 58
Introduction
Necessary tools - Advise for Windows users
Necessary tools - Node Version Manager (NVM)
Necessary tools - Docker and Docker Compose
Necessary tools - Postman and DBeaver
Installing VSCode
Repo for this course
Initial setup
Adding all the dependencies
Configuring Babel, Jest and Nodemon
Creating and connecting to the database
Understanding JWT
Understanding Bcrypt
Adding environment variables
Creating utils for JWT
Creating the database class
Registering the models
Adding the server
Adding tests helpers
Models overview
Creating the User model (Part 1)
Creating the User model (Part 2)
Creating the User model (Part 3)
Defining the Role model
Adding Refresh Token mode
Inspecting the new tables with DBeaver
Configuring the Sequelize CLI
Adding User migration
Adding Role migration
Adding Refresh Token migration
Applying migrations
Small improvement to the User model
Adding User model tests (Part 1)
Adding User model tests (Part 2)
Adding User model tests (Part 3)
Adding User model tests (Part 4)
Adding User model tests (Part 5)
Adding Role model tests
Create the Express app
Creating an Errors middleware
Creating a wrapper to handle async code
Creating an authentication middleware
Adding structure to the controllers
Adding the register controller
Adding tests for the register controller
Adding the login controller
Adding another test helper
Adding tests for the login controller
Adding a token controller
Adding tests for the token controller (Part 1)
Adding tests for the token controller (Part 2)
Adding the logout controller
Adding tests for the logout controller
Looking at the coverage of our tests
Listening for connections
Testing the app manually with Postman
Learning how to use the debug script
Conclusion