Skip to main content

Posts

A Blazor WebAssembly CRUD Sample Using MudBlazor Components

In this article, using the MudBlazor UI component we will implement a CRUD sample in Blazor WebAssembly. Create A Blazor WebAssembly Sample Application: To accomplish our goal let's create a sample Blazor WebAssembly application. Install MudBlazor Package: Package Manager: Install-Package MudBlazor -Version 5.0.7 .Net CLI dotnet add package MudBlazor --version 5.0.7 MudBlazor Setup: Add Mudblazor namespace into the '_Imports.razor' _Imports.razor: @using MudBlazor Add the below CSS files inside of the head tag in 'index.html'. wwwroot/index.html: <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" /> <link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" /> Remove the CSS files like 'bootstrap.min.css' and '{your_applicationname}.style.css'. Add MudBlazor javascript file in 'index.html' just above the closing bod

A Small Guide On NestJS Queues

NestJS Application Queues helps to deal with application scaling and performance challenges. When To Use Queues?: API request that mostly involves in time taking operations like CPU bound operation, doing them synchronously which will result in thread blocking. So to avoid these issues, it is an appropriate way to make the CPU-bound operation separate background job.  In nestjs one of the best solutions for these kinds of tasks is to implement the Queues. For queueing mechanism in the nestjs application most recommended library is '@nestjs/bull'(Bull is nodejs queue library). The 'Bull' depends on Redis cache for data storage like a job. So in this queueing technique, we will create services like 'Producer' and 'Consumer'. The 'Producer' is used to push our jobs into the Redis stores. The consumer will read those jobs(eg: CPU Bound Operations) and process them. So by using this queues technique user requests processed very fastly because actually

A .Net5 Sample Using CQRS(Command Query Responsibility Segregation) And MediatR Patterns

CQRS stands for Command Query Responsibility Segregation. CQRS guides us to separate our logical implementations into 2 categories like 'Commands', 'Query'. The 'Commands' specifies the operations like creation or updating of data into the data source(database). The 'Query' specifies the operations to fetch the data. In CQRS models(Request/Response classes) are independent or owned by a single operation, which means model classes can not be shared between the different 'Commands' or different 'Queries' or between a 'Command' and 'Query'. From the diagram one thing to observe Request/Response model(optional), that's because some times we will use query parameters or return a simple scalar type in those cases we won't create models. Create .Net5 Web API: To implement the CQRS pattern let's create a sample .Net5 Web API application. Configure Entity Framework Core Database Context: For this demo, I had created

Hot Chocolate GraphQL Custom Authentication Series Using Pure Code First Technique - Part4 - Refresh Token

Part3  we had enabled the JWT token validation and discussed different authorization techniques as well. In this article, we will understand Refresh Token creation and its usage. When To Use Refresh Token: A refresh token is a unique random encrypted string. On the expiration of the JWT auth access token, instead of showing a login page to the user, we can make the user authenticated immediately using the refresh token. By using refresh token we can fetch new user access tokens from the server without any user credentials. Generate Refresh Token: In 'AuthLogic.cs' file add a new private method like 'GenerateRefreshToken()'. Logics/AuthLogics.cs: private string GenerateRefreshToken() { var randomNumber = new byte[32]; using (var generator = RandomNumberGenerator.Create()) { generator.GetBytes(randomNumber); return Convert.ToBase64String(randomNumber); } } Here using 'System.Security.Cryptography.RandomNumberGenerator' generated refresh token of leng