
Compare real, in-memory, and SQLite testing databases, highlighting reliability and setup trade-offs. Then show configuring two Postgres databases with Docker Compose for local testing and straightforward connections.
Master the basics of json web tokens (jwt) for authentication and authorization by understanding header, payload, signature, signed vs encrypted tokens, and using them in authorization headers with stateless verification.
Initialize an express server by importing config, loading environment variables, and connecting to the database, then listen on the configured port within an immediately invoked function expression.
Inspect the newly synced Sequelize tables in Postgres with DBeaver, noting a unique email, a unique username, and the primary key. Explain why migrations provide a history of database changes.
Create and implement an authentication middleware that verifies bearer access or refresh tokens from the authorization header using jwt utilities, handles errors, and passes control to the next middleware.
Explore adding tests for the token controller middleware, covering invalid and missing authorization headers, bearer tokens, and 500 errors, with Jest spies on JWT utils.
Add logout controller and register in router. Retrieve the JWT from the request body, locate the user by email with the refresh token model, and return 200 with success true.
Add tests for the logout controller by issuing a post /logout with an access token, and verify 200 status, the message 'successfully locked out', and a nullified refresh token.
Connect to the database, set up a new app, import the default module to wire up controllers and models, and start listening on port 80.
Learn to use the debug script to attach the debugger, inspect variables, step through code, and diagnose issues in a sequelize orm app with express and postgres.
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.