
Learn clean architecture principles for a modular, scalable, and maintainable back-end with node.js and mongodb, build an enterprise-grade api, and test it with jest.
In this lecture, we will take a look at what our result will be.
What is Clean architecture? Some theoretical knowledge before coding.
In this lecture, we will create a project and a folder structure.
In this lecture, we will create a basic express server for our project.
Set up a node.js user entity by wiring index.js as entry and exporting a user class from user.js, with a constructor accepting an object for id, name, lastName, gender, meta.
Define an in-memory database stored in runtime memory, exporting an object with three arrays—users, products, and orders—via inMemory.js and index.js under a new database folder for repositories.
Build an in-memory users repository on the inMemoryDb, exporting userRepository with add, update, delete, and getByID, using uuidv4 for IDs.
Learn how to implement unit tests for a users repository with Jest in a Node.js API. Cover add, getByID, update, and delete operations using inMemory storage.
Add and export a product entity in the Node.js API course, using a single object for name, description, images, price, and color with defaults like price zero.
Create an in-memory products repository using the same structure as the users repository, and adapt the logic for products. Run the repository tests to verify the in-memory product logic works.
The lecture demonstrates writing and structuring repository tests for a node.js api, covering create, read, update, and delete operations for products using an in-memory setup.
In this lecture, we will create an order entity class that will follow us in the next steps.
Add an in-memory orders repository for the order entity, export it, and adapt the existing repository patterns from the products and users to support orders, then run tests.
Develop and validate comprehensive tests for the orders repository in a Node.js API, including creating, updating, and deleting orders, with mock data and parallel promise handling.
Define the add user use case by structuring a dedicated folder, injecting dependencies like the users repository, and encapsulating the business logic and validation rules for creating a user entity.
Learn to write unit tests for the user use case in a Node.js API, create mock repositories, generate test data with chance, and verify the user is saved correctly.
Implement the get user by id use case using the same structure as the zoo use case; wire the execute method to receive the id and return the user.
Learn to implement and validate the get user by id use case with tests, using mocks, fake data, and assertions to ensure correct user retrieval in a Node.js API.
Learn to implement an update user use case in a node.js api project, using a repository pattern, executing and saving the user, and exporting the use case.
Explore updating a user use case in a Node.js API by writing tests, using mock data, and validating integration between models and use case logic.
Execute the delete user use case as the leading user flow, emphasizing modular, dedicated logic with business validation and error checks to keep each use case separate from updates.
Explore a delete user use case test in a Node.js API, demonstrating straightforward integration checks that verify the function returns the expected user data and aligns with repository logic.
Learn to implement the add product use case in a Node.js API by modeling a product entity, wiring dependencies, exporting the model, and returning the executed product data.
Write a product use case test for a Node.js API. Create a test product, mock dependencies, run the use case, and verify the saved product matches the test data.
Explore the get product by id use case in a modular, well-structured Node.js API, focusing on fetching a product by its id without adding new products.
Test the get product by id use case in a Node.js api. Create a fake id, invoke the use case, and verify product includes id, name, description, images, and price.
Add and export a new update product use case in the Node.js API course, following the existing use case structure and reusing a template to implement update logic.
Develop and test the updated product use case by creating test data, calling the update function, and asserting that the repository returns the updated product.
Implement the delete product use case within a clean architecture, reuse existing patterns, and call the delete method to demonstrate consistent business logic.
Learn how to write a delete product use case test in a Node.js API, with per-use-case test organization, test data, and validation of expected outcomes.
Create and export the order use cases in a structured Node.js API, enabling testing of business logic with repositories, dependencies, and clear execution flows.
Learn to design and test the create order use case in a Node.js API, covering four use cases, dependencies, and mocks to validate order data.
Explore service contracts and building a consistent response structure for microservices and rest api, including a response class and an error object with status and reason.
Create and wire an add user controller in a Node.js API, wiring dependencies, validating request body, invoking the user use case, and returning a JSON response with error handling.
Implement a get user by id controller, wire it to the get user by id use case, manage dependencies, and return a json response.
Implement the delete user controller by routing the request to the delete user use case, wrapping the user in an object, and returning a structured response.
Update the user controller by copying the existing user controller pattern to the update use case and ensure the response is returned consistently.
Explore building a Node.js API with express routes and user controllers, using in-memory repositories and a rest API for CRUD on users, with error handling and environment-based configuration.
Begin by creating the product controller, wiring routes and dependencies, and connecting the product use case to execute and respond, with error handling using next.
Create the delete product controller and product use case, wire the flow, execute the use case, and use a breakpoint for debugging before moving the product.
Update the product controller in a node.js api by copying the existing controller, rewriting to update fields from the request body, initializing the use case, and returning a response.
Build and test a get product by id controller in a Node.js API using Express, separating logic with a use case to keep controllers decoupled and testable.
Create and initialize an order controller in controllers/orders, export an initialized controller object, wire it to the order use cases, process request body defaults, and handle responses with try/catch.
Develop a get order by id controller in a Node.js API, wiring the use case and handling the order id from the request for a streamlined retrieval.
Update order controller demonstrates copying an order, updating its data, and returning a consistent response contract while avoiding duplicate state in a Node.js API.
Create and wire a delete order controller in a Node.js express API, setting up the router, order use cases for update and delete, and basic tests.
Learn how to implement an express error handler that catches crashes, structures a proper response object with status 500 and message, and tests robust error handling in a Node.js API.
Shape business validations for adding an order by ensuring the user IP exists, handling validation errors with structured messages and fields, and integrating optional validation libraries in a Node.js API.
Fix tests after adding business validation rules by wiring use cases and in-memory repositories, ensuring correct get user and product validation flows in a Node.js api.
Initialize a Mongo connection with Mongoose by loading environment variables and the connection string, and exporting a connect function. Install Mongoose and log successful or failed connections.
Create a user schema using mongoose, define the last name field, export the schema from the schemas folder, and reference related product and order schemas.
In this lecture, we create a product schema by copying the user schema structure, defining fields like name, description, images, and meta data as an object, with crud considerations.
Create an order schema in a Node.js API using mongoose, including a user id reference and a products array to define the order object.
Create a Mongo users repository by defining a mongoose model and schema, exporting a reusable repository, and implementing create, update by id, and delete operations.
Learn to build a consistent products and orders repository with a CRUD architecture in a Node.js API, applying architecture principles, validators, dependencies, and Mongo integration.
In this course, we will create Node.js basic shop API using Express.js and MongoDB. We will start this journey by understanding what clean architecture means, and right after will dive deep into coding.
We will start this course using in-memory DB and after that will move our app to MongoDB and Mongoose. I made a decision to make the course this way to show you how it's easy to move from one library to another when you are using good architecture.
We will test out the application using jest with the newest test stack and methodologies.
In this course, you will see how to use dependency injections in a really easy format and what it gives you. We will also make business validations for entity creation and updates. I want to show you how to use the response contracts layer to give one look at your every response from the server.
We will create an Application error handler to handle every exception or error and respond to a formatted response.
After every step of this course, you will have hands-on exercises and an answer right after.
Join this course to make a cool Node.js server. Enjoy and be happy :)