
Build a shopping app with Node.js and Express using an advanced project structure, publish npm packages, deploy API, and use git with Stripe gs to store client cards without mongoose.
Install the TypeScript compiler via npm, verify with tsc -v, then generate tsconfig.json with tsc --init to target Ecmascript six, use Commonjs modules, and output to dist.
Learn TypeScript basics by declaring variables with string, number, and object types, enforcing type safety with optional properties, unions, and typed functions.
Explore advanced types in TypeScript, including interfaces, generics, type aliases, and enums, to model user data, login flow, and strict status handling with promises.
Design a multi-service api by separating buyer, seller, and auth into distinct javascript classes with dedicated models and routers, enabling stripe checkout and mongoose persistence.
Initialize the common package by setting up npm, TypeScript config, and git, create and export the current user middleware with JWT support, and prepare for npm publishing.
Publish our package to npm by creating an organization, logging in from the terminal, configuring main, types, and build paths, and bumping the version before a public publish.
Clean the build folder, compile with tsc, add two files to git, and publish a versioned npm package, correcting a dash m option and validating the publish workflow.
Enable the declare file option to generate index.d.ts for the package. Build the source, publish with npm, and ensure the build exports index.d.ts for app installation.
Set up a Node.js, TypeScript project structure with tsconfig and dist output, initialize git, install and wire express, mongoose, and dotenv, and prepare start scripts for running the app.
Implement authentication by building the earth service with routers and a mongoose user model, defining email and password as required fields, export the model named user.
Create types for user model by defining user doc and user model interfaces with mongoose, export them, and implement a json transform to map _id to id and omit password.
Export a user service class backed by the user model, implementing a create method with a create user DTO to save a new user and a find by email method.
Build an auth service with a signup method that checks for an existing email via the user service, creates a new user, and generates a JWT token.
Build and integrate the authentication service in the common package, implementing a generate jwt method, password hashing and comparison, and jwt verification with a global jwt payload interface.
Hash passwords before saving in the user model using a pre save hook with an authentication service, then implement sign in with credential verification and jwt issuance.
Create auth routers in Express to handle sign up, sign in, and current user, using JWT tokens, async handlers, and middleware for error handling and user retrieval.
Wire up auth routers in app.module, fix current user dto to auth dto, run api on port 8080, and prepare to test sign up and sign in with Postman.
Test the auth routers with Postman by sending signup and signin requests to localhost:8080, inspect JWT tokens in cookies and authorization header, and verify current user data and error handling.
Create and connect a new GitHub repository, push code with an initial commit to the main branch, and switch to the development branch for ongoing work.
Create the seller service's product model with a mongoose schema, linking to the user document, and define corresponding TypeScript interfaces and exports to support product creation, images, and pricing.
Implement an uploader class in the common package to handle product image uploads via a mil ter based middleware, with file filtering and disk storage in the new router.
Configure and apply the uploader class middleware to handle multiple image uploads, define middleware options, enforce png and jpeg types, handle upload errors, and integrate with seller and product services.
Create the product service's create method, defining create product detail, generating image sources from uploaded files, and saving the product with title, price, user, and images.
Finish the new product router by wiring a seller service to the product service, moving constants to a single file, and enforcing current user and auth middleware for product creation.
Refactor the product service to generate a buffer with fs readFileSync instead of file.buffer, and update the uploader path and default directory to upload images correctly.
Implement the update product flow by adding update product detail to the product service and updating the product model with find one and update for title and price.
Learn how to create and extend custom error classes, use instance of custom error for safe handling, and leverage the error service in a Node.js TypeScript shop API.
Delete a product via a protected route by validating the product id and ownership, using a delete product DTO and service method, and returning a simple success boolean.
Implement image management for products by adding and deleting images through new api routes, with product service methods, dto definitions, and file handling using push and pull operations.
Push seller service updates to GitHub by git add, git commit -m, and git push -u origin development, using a personal access token.
Learn to amend the last commit by adding changes, then pull the latest from development and push to the development branch using a recursive merge strategy.
Define the buyer service cart model with a total price and an array of cart products. Create a cart product model that references a product and stores the ordered quantity.
Define the cart model with a user reference, a products array of cart product ids, and a required total price; export cart and cart product models and interfaces.
Create and export a cart service class and its instance in the cart folder, implement the constructor using the cart model and cart product model, and add a find-one-by-user-id method.
Add product to cart checks for an existing cart, creates one if needed, creates a cart product document, and adds or increments items while updating the cart total.
Implement cart management by checking whether a product exists in a cart, then add or update its quantity with increment/decrement handling and total price updates.
Implement a delete flow to remove a cart product by cart id and product id, update the cart total, and remove the item from the products array.
Export the buyer service with a constructor accepting cart and guard services, implement add product to cart using product service validation, and raise bad request if missing.
Create cart/add route on the buyer router to add a product to the cart using product id, quantity, and user id, with auth, error handling, and returning the updated cart.
Design and implement a router to update cart product quantity in the buyer service, using a dedicated DTO and a cart product quantity detail interface, updating the cart service accordingly.
Implement get cart product by id in the cart service, using product id and cart id. Update the cart product quantity via the card service and handle not found cases.
Implement a new buyer router to update cart product quantity, parsing cart id, product id, amount, and increment, validating increment, and returning the updated cart with status 200.
Implement robust cart error handling by returning the updated cart in the update quantity route and emitting a clear error when the cart is missing, avoiding null responses.
implement delete product from cart and get cart routers, validate cart and product existence, ensure cart belongs to the user, and store cart id in session for upcoming stripe payments.
Explore Stripe as a payment solution, create your Stripe account, sign in to the dashboard, and prepare to integrate Stripe in your shop API project.
Copy Stripe secret key from the dashboard and save it in the dot env file as stripe key in test mode. Use the publishable key on the front end.
Install stripe and types, implement a checkout method that validates the cart, creates or reuses a Stripe customer, charges the cart total, and clears the cart by creating an order.
Check for an existing customer, then create one if missing, save the customer ID to the cart, process the charge, clear the cart, and create the order.
Create a mongoose order model with user id, total amount, and charge id, export it, and define a create order method in the order service using a create order dto.
Implement the create order flow by saving the order with the order service during checkout, wiring the buyer service to stripe using cart total price, user id, and charge id.
Create a buyer service handler to update a customer's stripe card, validate the customer id, use the stripe service, and wire it into the buyer router for a successful update.
Sign in, create a product with an image, add it to the cart, and complete a stripe checkout to test payments using the shop api powered by node.js and typescript.
Automate deploying the shop API with GitHub actions and Heroku, building and testing on pull requests, using a CI/CD workflow with node, npm ci, and TypeScript.
Configure a GitHub Actions deploy job on ubuntu latest, integrating checkout and Heroku deployment. Securely manage secrets with GitHub Secrets and define the dist outdir for the TypeScript app.
Configure heroku deployment with a proc file and port, and define a start dev script to run the api. Push to git, trigger github actions, deploy, and test with postman.
Welcome to "Advanced Shopping API Development with Node.js, TypeScript, Stripe, and Mongoose"! This Udemy course is designed for intermediate and advanced developers who already have a solid understanding of Node.js, Express, and Mongoose and want to take their skills to the next level.
In this hands-on course, we'll dive deep into building a powerful shopping API from scratch using advanced techniques and industry-standard tools. By the end of this course, you'll be equipped with the expertise to develop robust and scalable e-commerce APIs that handle real-world scenarios.
Course Highlights:
Node.js and TypeScript Refresher: Brush up on essential Node.js and TypeScript concepts, ensuring you have a strong foundation before diving into the advanced topics.
Advanced API Design: Learn how to architect a well-organized API, employing best practices and design patterns for scalability and maintainability.
MongoDB with Mongoose: Leverage Mongoose to interact with MongoDB efficiently and handle complex data models.
Error Handling and Middleware: Master advanced error handling techniques and create custom middleware to enhance your API's reliability and performance.
JSON Web Tokens (JWT) for Authentication: Implement secure user authentication and authorization using JWT, ensuring a safe user experience.
Seamless Payment Processing with Stripe: Integrate the Stripe payment gateway to enable smooth and secure online transactions.
Performance Optimization: Optimize your API's performance with caching, indexing, and other performance-enhancing techniques.
Custom NPM Packages for Reusability: Create and publish custom NPM packages to modularize your code and boost reusability across projects.
Throughout this course, you'll work on a practical shopping API project, putting your newfound skills into action and gaining hands-on experience. We'll also cover advanced topics in Node.js development, enabling you to build efficient, maintainable, and production-ready APIs.
If you're ready to take your Node.js and API development skills to new heights, this course is tailor-made for you. Join us now and become an expert in building sophisticated shopping APIs with Node.js, TypeScript, Stripe, and Mongoose. Let's embark on this exciting journey together! Enroll today and level up your developer expertise!