
In this section, we are going to learn the basics of Nodejs and we are going to build the basic web server in nodejs
Replace the Node.js http module with the Express framework, set up get, post, put, and delete routes, and return JSON responses with proper status codes.
Learn how Prisma converts models written in its schema language into SQL database tables, defines relationships, and migrates an SQLite database while building a basic application.
Set up a video model in Prisma, link it to courses with a one-to-many relationship, and insert records with the Prisma client in Node.js using a Postgres database.
Learn how to find many records and create one-to-many relationships between courses and videos, and between instructors and courses, using prisma, nodejs, and postgres.
Demonstrate linking a newly created video to a course by inserting records with Prisma, setting the course ID, and retrieving the related course data.
Configure prisma data sources and database connections (sqlite, sql, mongo) via the .env url, generate types with prisma generate, and define relations using foreign keys.
Build an Express server with get, post, update, and delete endpoints for courses, using Prisma to fetch records. Install Express and types, set the port, and test with HTTP clients.
Learn how middleware works in Express, including application level, router level, built-in, third-party, and custom middleware, and create a custom logger that uses next to proceed.
Learn to add third-party middleware like Morgan in Express, install and configure it for development logging, and implement error handling and body parsing with express.json.
Refactor the app by packaging routes in a dedicated router with separate course handlers, using Prisma for data access, and mounting under api for a cleaner api structure.
Learn to implement find by id for courses using prisma's findUnique in a Node.js TypeScript router, including id handling, validation, and error responses (404, 400) with debugging tips.
Implement JSON Web Token authentication by building a sign up route, validating inputs, encrypting the password with bcrypt, saving the user via Prisma in Postgres, and creating the user model.
Implement login functionality by validating email and password, finding the user by email, and issuing a JSON web token after a successful password match.
Install, import, and create a json web token with a user id payload and secret, then return the token on login for authenticated routes via header.
Build and apply a JSON web token authentication middleware for a private route, validating the token in headers, extracting user id, and handling 401 errors.
Implement a one-to-one relationship between user and instructor in the Prisma schema, allowing a user to create an instructor account, removing instructor emails, migrating, and testing with a token.
Explore offset-based and cursor-based pagination in Prisma, with a course data example, including filtering, sorting, and per-page limits, and when to use infinite scrolling for mobile social apps.
Learn to connect a Prisma app to Postgres by updating the database URL, creating a Postgres database via pgAdmin, and running migrations to replace SQLite with Postgres.
Learn to implement prisma nested queries by creating customer, address, and application models with 1-to-1 and 1-to-many relationships, including an application type enum and transactional nested creates.
Demonstrates using Prisma's transaction API for independent sequential queries, allowing multiple finds (applications, customers, courses) in a single operation, with all-or-nothing rollback on failure.
Learn interactive transactions in a banking transfer flow, wrapping balance updates in a transaction so a failure rolls back all steps using Prisma, Node.js, and Postgres.
Set up Jest with TypeScript, install TypeScript as a dev dependency, and write tests with describe and it, including mocking, setup and teardown, and testing asynchronous code and read API.
Master object assignment matcher and deep equality in api tests by organizing test blocks, adding properties like education to pass tests in prisma nodejs postgres projects.
Master the not to be matcher in tests by using expect statements to invert outcomes; verify that ten plus fifteen equals twenty-five and adjust expectations to pass the test.
Master ES6 template literals to interpolate variables with backticks, dollar signs, and braces, render HTML using template strings, map and join arrays, and sanitize output with DOMPurify.
Explore es6 modules in a webpack project, mastering default and named exports, imports, and a config api key setup. See how bundling with webpack creates a bundle for the index.html.
Explore prototype inheritance and class-based design by creating constructors, classes, and methods. Extend classes, implement getters, setters, static methods, and array operations like find, push, and iterating with for... of.
Explore promise chaining and the switch to async/await, handling success and errors with then, catch, and try/catch; learn to fetch multiple GitHub users with Promise.all and parse JSON.
Prisma is a next-generation object–relational mapper (ORM) that claims to help developers build faster and make fewer errors. Prisma takes a different approach to ORMs compared to traditional ORMs. It uses a custom Schema Definition Language (SDL) that automatically writes migrations and generates type-safe code.
Why Prisma?
ORMs facilitate implementing the domain model. The domain model is an object model that incorporates the behavior and data of your business logic. In other words, it allows you to focus on real business concepts rather than the database structure or SQL semantics.
ORMs help reduce the amount of code. They save you from writing repetitive SQL statements for common CRUD (Create Read Update Delete) operations and escaping user input to prevent vulnerabilities such as SQL injections.
ORMs require you to write little to no SQL (depending on your complexity you may still need to write the odd raw query). This is beneficial for developers who are not familiar with SQL but still want to work with a database.
Many ORMs abstract database-specific details. In theory, this means that an ORM can make changing from one database to another easier. It should be noted that in practice applications rarely change the database they use.
In this course, we are going to build the REST API in Prisma, Node, Express, and Postgres