
Explore building production-ready applications with Prisma client for NodeJS, covering setup, CRUD operations, SQL relations, advanced techniques, and AWS deployment.
Practice what you learn with Prisma client for Node.js by coding along, building data models, and mastering CRUD and complex queries; apply to real projects and build production-ready apps.
Identify prerequisites in JavaScript basics and NodeJS with Express, then outline tools for this course including Prisma, Postman, VS Code, and MySQL Workbench across Mac, Linux, and Windows.
Initialize a Node and Express project to explore Prisma, set ES6 module type, install Express and Nodemon, create index.js with a hello Prisma route, and run on port 3000.
Initialize Prisma, configure MySQL in env, define an articles model with id, title, content, and state enum (draft, published) with created and updated timestamps, then run migrate dev.
Use migrations to manage database schema changes, track edits like git, and keep all team environments in sync, including alternatives like Prisma Studio for CRUD operations.
Install prisma client and body parser, instantiate the prisma client, and create routes to insert one article or many with data from the request body, validating input.
Learn how Prisma client logs reveal the exact SQL generated behind the scenes when inserting data, and use log configuration to debug queries against the Prisma articles table.
Retrieve articles with Prisma client using find many and find first, and fetch a single article by id or by draft state. Learn via Prisma Studio and Postman.
Learn to update a single or multiple articles using Prisma Client in Node, building put route, parsing IDs from params or body, and updating with where, data, and update many.
Learn how to delete records with Prisma in node apps, including creating a delete route and removing a single article by id with prisma.article.delete. Also note delete many risks.
Explore how Prisma Client handles database relations, including one-to-one, one-to-many, and many-to-many. Learn with examples like users and profiles, users and orders, and books and authors.
Learn to implement a one-to-one relation in Prisma by linking a user and a profile with a unique userId foreign key, and apply migrations.
Learn to implement one-to-one relations with Prisma Client by creating a user and a linked profile, then fetch the user with the profile included.
Validate the one-to-one relation between user and profile by enforcing a unique constraint on the profile user ID, then fetch users with or without profiles using Prisma.
Establish a one-to-many relation in Prisma by linking the article and user tables with a foreign key user_id and an articles array.
Insert an article for a user using Prisma Client for NodeJs in a one-to-many relation. Fetch user, build data with title, content, and draft state, and create the article.
Explore handling one-to-many relations with Prisma client in Node.js by fetching users with article counts, listing published articles only, and deleting unpublished posts.
this lecture demonstrates many-to-many relations in Prisma using three tables (user, product, tag) and focuses on implicit relations where Prisma creates the pivot table called product to tag automatically.
Use existing tags to a newly created product using Prisma's connect, avoiding tag creation, and learn to fetch all products for a tag and all tags for a product.
Create an explicit many-to-many relation by building a custom pivot table for a cart, linking users and products with a quantity field in Prisma.
Learn how to add a product to a user’s cart with Prisma in Node.js: fetch the user and product, assemble userId, productId, and quantity, then create the cart entry.
Fetch a user's cart via Prisma client for nodejs, retrieving a many-to-many relation through the explicit pivot table with products and quantities.
navigate prisma docs to access the client api and schema references, explore aggregate functions (count, average, min, max), and learn relation queries like delete and update many.
Explore advanced Prisma concepts, including sequential and interactive transactions, nested writes, and custom validations before insertion or update, then learn about computed fields, raw SQL queries, and pagination.
Explore transactions and batch queries with Prisma. Learn the atomicity of a money transfer between two accounts, with rollback on failure and Prisma transaction APIs for nested and sequential operations.
Explore sequential transactions with Prisma client in node.js, implementing a route that fetches draft articles and returns the count using a transactions array that rolls back on failure.
Use interactive transactions with Prisma client in node to create a user and its profile together, with async logic and rollback on unique constraint conflicts.
Learn how nested writes work in Prisma by creating a user and its related articles in a single transaction, with automatic rollback on failure.
Learn to execute raw sql queries in Prisma using queryRaw, fetch articles by user id, and join users to include email information.
Implement pagination in Prisma to fetch articles in chunks using skip and take. Understand why pagination improves performance over full table traversal and adopt limit offset pagination in your backend.
Use Zod to implement production-level validations for article creation by extending the Prisma client, validating title, content, and state via schema.parse, with try-catch error handling.
Implement computed fields in Prisma to generate a full address from name, address, and phone number by extending the profile query with client extensions and preview features.
Build a production-grade e-commerce app with Prisma Client for Node.js, featuring authentication, role-based access, and full-text product search using TypeScript, Express, and Prisma.
Set up a production-ready node project by initializing npm, adding TypeScript with tsconfig, installing express and node types as dev dependencies, and creating a source folder.
Create a basic express app with a home route, fix the import typo (express not exp), install ts-node and nodemon for TypeScript development, and run on port 3000.
Import express types to type request and response, enabling compile-time checks, and organize the project by creating folders inside source for middlewares, exceptions, controllers, schemas, and routes.
Install prisma and prisma client, then initialize prisma to create the prisma directory with schema.prisma configured for MySQL. Create an e-commerce database on localhost and prepare for prisma migrate.
Configure prisma with mysql for ecommerce database, define a users model with id, name, email, password, created at, updated at, migrate users table, and set up routes and login api.
Set up environment variables by replacing hardcoded ports with a .env file using dot env, export port from process.env, ignore the file in git, and provide a .env.example template.
Define auth routes with an express router, create a dedicated auth routes file and login controller with request and response types, and apply an api prefix in a single index.ts.
Initialize the Prisma client and implement signup with bcrypt hashing and json web token authentication, validating users, creating accounts, and preparing login routes.
Finish the login route with email and password. Verify the user with bcrypt, issue a JWT token using the user id and secret, and exclude the password from responses.
Learn structured error handling in node.js by building a custom http exception class, error codes, and an express error middleware to standardize responses.
Validate signup inputs with zod by defining a signup schema for name, email, and password, and enforce it before prisma create to ensure robust error handling.
Implement a generic error handler in Node and TypeScript by wrapping controllers in a higher-order function, handling http and internal exceptions, and standardizing 500 errors and codes.
Replace generic login errors with custom not found 404 and bad request 400 exceptions, by throwing a not found exception and a bad request exception in the login controller.
See how auth middleware extracts the token from the authorization header, verifies it with JWT, fetches the user from the payload via Prisma, and attaches it for /me.
Add role based access management by introducing a role enum with admin and user in the user model, defaulting to user, and enable management via Prisma Studio and migrations.
Learn to implement role-based access for product creation with auth and admin middlewares, create a prisma client product, transform tags array to comma separated string, and validate requests.
Finish the product routes by implementing update, delete, list with pagination, and get by id using Prisma client. Handle MySQL text field, comma-separated tags, and not-found errors with proper paging.
Handle validation errors by detecting Zod validation errors and returning unprocessable entity responses, surfacing messages such as 'password is required' during sign up.
Create the address model with line one, line two optional, city, country, and pin code. Link it to user via user_id to create relation, migrate, and add routes for addresses.
Finish the address routes, define an address schema (line1, line2 nullable, pincode six, country, city, user id), validate the user via Prisma, create the address, and handle user not found.
Authenticate users with tokens, fetch the current user from request.user, and finish address routes with prisma. List the user’s addresses without pagination and handle address not found with code 1004.
Learn to build an update user controller with auth, update default shipping and billing addresses in Prisma, validate inputs with update user schema, and enforce address ownership.
Define the cart items model with user and product relations and a quantity field, create the corresponding migration to build the cart items table, and prepare for controllers.
Build a cart system with add, delete, and quantity updates, and list all items for a user using a cart controller and Prisma client, with route setup and product checks.
Implement and test get cart and change quantity routes in a Prisma client for NodeJs app, with input validation, updating cart items, and including product data.
Define and relate order, order_product, and order_event models to manage orders, products, quantities, addresses as strings, and statuses (pending, accepted, out for delivery, delivered, cancelled) with migrations.
Create an order route using prisma transactions to validate cart items, calculate total, fetch and format user addresses, create orders with related order products and events, then clear the cart.
Add a current status field to the order schema with type order event status and default pending, storing the status in the order model while preserving history of order events.
Finish user order routes by listing orders with related products and events, retrieving by id, handling not found errors, and implementing cancel via transactional updates and event creation.
Define and implement admin routes for user management, including paginated list users, get user by id with addresses, and change role; manage orders and search products with full text search.
Implement and test admin order routes with Prisma Client for Node.js, including listing all orders, listing a user’s orders, and changing order status with optional status filters, pagination, and transactions.
Learn to implement full text search across multiple product fields using Prisma with Node.js, enabling preview features, and configuring indexes on name, description, and tags.
Access the source code on my GitHub profile in the Prisma Resources repository and clone it. Deploy to your own servers using your env files.
Move your Prisma project to production by configuring Prisma, migrating database tables, and deploying the NodeJS application on AWS with EC2 and RDS MySQL behind a load balancer.
Learn to manage AWS costs while building production-ready apps, leverage the free tier, read pricing docs, and dispose of resources to avoid extra charges.
Set up a new AWS account, configure Route 53 DNS and ACM SSL certificates, perform DNS validation with CNAME records, and choose regions to prepare for database deployment.
Create a security group in EC2, set inbound rules for ssh, http, https, mysql 3306, and port 3000, then proceed to create the database.
Learn to configure an AWS RDS MySQL database: enable the free-tier t2 micro, private access, a security group, backups, and capture endpoint credentials for later EC2 deployment.
Launch an EC2 instance by selecting ubuntu 22.04, using the free tier t2 micro, and creating a key pair for SSH authentication; configure the e-commerce security group and launch.
SSH into an EC2 instance with a pem file, set permissions, install node via nvm, verify node and npm, then prepare to pull code from GitHub and install dependencies.
Prepare production by adding a build script, configure tsconfig.json outDir to build, run npm run build to generate JavaScript in the build folder, and push to the EC2 server.
Clone a GitHub repo on an EC2 instance, create and configure the .env from a template, run npm install, npm run build, and start the app with node index.js.
Deploy migrations in production with Prisma migrate deploy to apply changes, then run the Node.js app with PM2 and verify APIs under the /api prefix.
Set up a load balancer and target group named eCommerce on port 3000 for the NodeJS app. Attach the https certificate and route traffic to the target group.
Configure Route 53 with a hosted zone, create an A alias pointing to an application load balancer in US East 1, enable https, and deploy a Node.js app to production.
Learn to clean up a deployed Node.js app on AWS by deleting Route 53 records, load balancers, target groups, EC2 instances, and RDS databases to avoid costs.
Course Description (200+ words):
"Building Production-Ready Applications with Prisma Client for Node.js" is a comprehensive and hands-on course designed to empower developers with the skills and knowledge needed to create high-performance, scalable, and production-ready applications using Prisma Client in the Node.js environment.
In today's fast-paced development landscape, it's crucial to stay at the forefront of technology, and this course offers precisely that. With six comprehensive modules, we cover a wide array of topics to ensure you are well-equipped to tackle real-world application development.
We begin with a foundational module where you'll receive a thorough introduction to Prisma and set up a Node.js Express application, creating the ideal environment for your Prisma journey. Following this, you'll dive into the world of CRUD (Create, Read, Update, Delete) operations with Prisma, a fundamental skill for any database-driven application.
Our course goes beyond the basics, delving deep into SQL relationships, allowing you to create and manage data models and their connections effectively. As you advance through the modules, you'll explore advanced concepts and techniques, such as data validation, pagination, transactions, and even crafting raw SQL queries for intricate data operations. These skills will set you apart as a versatile developer capable of handling complex real-world scenarios.
The fifth module is where you put your knowledge into practice, building a production-ready application with Node.js and TypeScript, incorporating Prisma for database interaction. You'll learn how to structure your project and apply Prisma concepts, ensuring the final product adheres to industry standards.
In the bonus module, you'll discover the vital skill of deploying your application to AWS, a key aspect of bringing your projects to life. You'll explore AWS services like Route53 for domain management, EC2 for application hosting, RDS for your database, and Load Balancers to ensure high availability.
This course is suitable for both beginners looking to build a strong foundation in modern application development and experienced developers seeking to enhance their skills. Upon completion, you will be equipped to create robust, efficient, and industry-standard applications, and take them from development to production, serving users on the web with confidence. Dive into Prisma and elevate your Node.js development to new heights with us.