Skip to main content

Posts

Showing posts with the label Rate Limiting

๐Ÿš€Master User Authentication in .NET 8 Web API Email Confirmation, Password Reset, 2FA & Lockout with JWT & Identity๐Ÿ”

Part 5️⃣ - Ocelot Gateway API๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

Ocelot Configuration File - ocelot.json This configuration file sets up routes for an API Gateway using Ocelot. The gateway manages requests for three main services: Authentication, Product, and Order APIs. Here's a detailed description of each section: Authentication Routes Path : /api/authentication/{everything} Host : localhost:5000 Methods : GET, POST, PUT, DELETE Rate Limiting : Allows 1 request per 10 seconds. Product Routes Get All Products Path : /api/products Host : localhost:5001 Method : GET Caching : 60 seconds with custom header eCommerce-Caching-Control . Get Product By ID Path : /api/products/{id} Host : localhost:5001 Method : GET Caching : 60 seconds with custom header eCommerce-Caching-Control . Modify Products Path : /api/products/{everything} Host : localhost:5001 Methods : POST, PUT, DELETE Authentication : Bearer token required. Order Routes Get All Orders Path : /api/orders Host : localhost:5002 Method : GET Caching : 20 seconds with custom header eCommerce-C

Part 4️⃣ - JWT Authentication API |๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

Entity Description - AppUser AppUser Class Description The AppUser class represents a user in the application, encapsulating various properties related to user identity, contact information, and roles. Here’s a detailed breakdown of each property: Id Type : int Description : A unique identifier for the user. Name Type : string? Description : The user's name. It is nullable, allowing the possibility of no name being provided. TelephoneNumber Type : string? Description : The user's telephone number. It is nullable. Address Type : string? Description : The user's physical address. It is nullable. Email Type : string? Description : The user's email address. It is nullable. Password Type : string? Description : The user's password for authentication. It is nullable. Role Type : string? Description : The role assigned to the user (e.g., Admin, User). It is nullable. DateRegistered Type : DateTime Description : The date and time when the user registered. It defaults to th

Part 3️⃣ - Order API |๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

Domain Layer Order Entity The Order entity represents an order within the e-commerce system. It captures essential details related to a customer's purchase and is a core component of the Order API. Properties Id : Type: int Description: Unique identifier for the order. This serves as the primary key in the database. ProductId : Type: int Description: Identifier for the product associated with the order. This links the order to a specific product in the Product API. ClientId : Type: int Description: Identifier for the client who placed the order. This associates the order with a specific customer. PurchaseQuantity : Type: int Description: The quantity of the product purchased in the order. OrderedDate : Type: DateTime Description: The date and time when the order was placed. Defaults to the current UTC time when the order is created. Summary The Order entity is a crucial part of the Order API, encapsulating the data required to manage and process customer orders. It link

Part 2️⃣ - Product API |๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ - [Part 2️⃣] Product Description This code defines the Product class within the ProductApi.Domain.Entities namespace. The Product class represents a product entity with properties commonly associated with products in an e-commerce application. Features Id : Represents the unique identifier for the product. It is an integer property and serves as the primary key for the product entity. Name : Represents the name of the product. It is a nullable string property, allowing the product name to be optional. Price : Represents the price of the product. It is a decimal property, ensuring accurate representation of the product's cost, including fractions of currency units. Quantity : Represents the quantity of the product available in stock. It is an integer property, indicating the number of units of the product that are available. Usage Data Representation : The Product class is used to rep

Part 1️⃣ - Common Shared Library |๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

RESPONSE This code defines a C# record named Response with two properties: Flag , a boolean initialized to false , and Message , a string that defaults to null . Records in C# are immutable reference types that provide built-in functionality for value equality and concise syntax for defining data containers. GLOBAL EXCEPTION This code defines a middleware class named GlobalException for handling exceptions and specific HTTP response statuses in an ASP.NET Core application. The middleware checks for and modifies responses with status codes 401 (Unauthorized), 403 (Forbidden), and 429 (Too Many Requests). It also handles internal server errors and request timeouts by logging the exceptions and sending user-friendly error messages in JSON format. Key components of this middleware include: Dependencies : Uses Microsoft.AspNetCore.Http , Microsoft.AspNetCore.Mvc , System.Net , and System.Text.Json . Constructor : Takes a RequestDele