diff --git a/.version b/.version
index 217625a..636ed6a 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-1.0.0.1
\ No newline at end of file
+1.0.1.2
\ No newline at end of file
diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj
index b6dcaec..7b4e911 100644
--- a/Brizco.Api/Brizco.Api.csproj
+++ b/Brizco.Api/Brizco.Api.csproj
@@ -6,8 +6,8 @@
enable
Linux
..\docker-compose.dcproj
- 1.0.0.1
- 1.0.0.1
+ 1.0.1.2
+ 1.0.1.2
@@ -112,8 +112,28 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Brizco.Api/Controllers/BrewController.cs b/Brizco.Api/Controllers/BrewController.cs
new file mode 100644
index 0000000..46d4d19
--- /dev/null
+++ b/Brizco.Api/Controllers/BrewController.cs
@@ -0,0 +1,41 @@
+using Brizco.Core.MartenServices.Abstracts;
+using System.Text.Json;
+
+namespace Brizco.Api.Controllers;
+
+public class BrewController : ICarterModule
+{
+ public void AddRoutes(IEndpointRouteBuilder app)
+ {
+ var group = app.NewVersionedApi("Brews")
+ .MapGroup("api/brew")
+ .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
+
+ group.MapGet("{brewName}/latest", GetLatestBrewAsync)
+ .WithDisplayName("Get Latest Brew")
+ .WithDescription("Get latest brew that has been set for day , you have pass recipe name in route")
+ .HasApiVersion(1.0);
+
+ group.MapGet("{brewName}", GetBrewAsync)
+ .WithDisplayName("Get Brew")
+ .WithDescription("Get brew that has been set for days , you have pass recipe name in route")
+ .HasApiVersion(1.0);
+
+ group.MapPost("{brewName}", AddBrewAsync)
+ .WithDisplayName("Add Brew")
+ .WithDescription("Add latest brew that has been set for day , you have pass recipe model")
+ .HasApiVersion(1.0);
+ }
+
+ private async Task GetLatestBrewAsync([FromRoute] string brewName, [FromServices] IBrewService brewService, CancellationToken cancellationToken)
+ => TypedResults.Ok(await brewService.GetLastBrewAsync(brewName, cancellationToken));
+
+ private async Task GetBrewAsync([FromRoute] string brewName, [FromServices] IBrewService brewService, CancellationToken cancellationToken)
+ => TypedResults.Ok(await brewService.GetBrewAsync(brewName, cancellationToken));
+
+ private async Task AddBrewAsync([FromRoute] string brewName, [FromBody] JsonDocument recipeObj, [FromServices] IBrewService brewService, CancellationToken cancellationToken)
+ {
+ await brewService.AddBrewAsync(brewName, recipeObj, cancellationToken);
+ return TypedResults.Ok();
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Api/Controllers/RecipeController.cs b/Brizco.Api/Controllers/RecipeController.cs
deleted file mode 100644
index 30b0b36..0000000
--- a/Brizco.Api/Controllers/RecipeController.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Brizco.Core.MartenServices.Abstracts;
-using Marten;
-using System.Text.Json;
-
-namespace Brizco.Api.Controllers;
-
-public class RecipeController : ICarterModule
-{
- public void AddRoutes(IEndpointRouteBuilder app)
- {
- var group = app.NewVersionedApi("Brews")
- .MapGroup("api/brew");
-
- group.MapGet("{recipeName}/latest", GetLatestBrewAsync)
- .WithDisplayName("Get Latest Brew")
- .WithDescription("Get latest brew that has been set for day , you have pass recipe name in route")
- .HasApiVersion(1.0);
-
- group.MapPost("{recipeName}", AddBrewAsync)
- .WithDisplayName("Add Brew")
- .WithDescription("Add latest brew that has been set for day , you have pass recipe model")
- .HasApiVersion(1.0);
- }
-
- private async Task GetLatestBrewAsync([FromRoute] string recipeName,
- [FromServices] IBrewService brewService, CancellationToken cancellationToken)
- => TypedResults.Ok(await brewService.GetLastBrewAsync(recipeName, cancellationToken));
-
- private async Task AddBrewAsync([FromRoute] string recipeName,
- [FromBody] JsonDocument recipeObj, [FromServices] IBrewService brewService,
- CancellationToken cancellationToken)
- {
- await brewService.AddBrewAsync(recipeName, recipeObj, cancellationToken);
- return TypedResults.Ok();
- }
-}
\ No newline at end of file
diff --git a/Brizco.Api/Program.cs b/Brizco.Api/Program.cs
index d8dd0af..c84546c 100644
--- a/Brizco.Api/Program.cs
+++ b/Brizco.Api/Program.cs
@@ -91,7 +91,7 @@ var app = builder.Build();
app.UseCors("CorsPolicy");
-app.UseSwagger();
+app.UseCustomSwagger(siteSetting.BaseUrl);
app.MapScalarUi();
app.UseAuthorization();
diff --git a/Brizco.Api/Services/CurrentUserService.cs b/Brizco.Api/Services/CurrentUserService.cs
index cc952d3..945409d 100644
--- a/Brizco.Api/Services/CurrentUserService.cs
+++ b/Brizco.Api/Services/CurrentUserService.cs
@@ -16,5 +16,6 @@ public class CurrentUserService : ICurrentUserService
public string? UserName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name);
public string? ComplexId => _httpContextAccessor.HttpContext?.User?.FindFirstValue("ComplexId");
public string? RoleId => _httpContextAccessor.HttpContext?.User?.FindFirstValue("RoleId");
+ public string? FullName => _httpContextAccessor.HttpContext?.User?.FindFirstValue("FullName");
public List? Permissions => _httpContextAccessor.HttpContext?.User?.FindAll("Permission")?.Select(c=>c.Value)?.ToList();
}
\ No newline at end of file
diff --git a/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs b/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs
index 064ffa3..9e8cf24 100644
--- a/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs
+++ b/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs
@@ -131,7 +131,11 @@ public class ExceptionHandlerMiddleware
Formatting = Formatting.Indented
});
- context.Response.StatusCode = (int)httpStatusCode;
+
+ if (httpStatusCode == HttpStatusCode.InternalServerError)
+ context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
+ else
+ context.Response.StatusCode = (int)httpStatusCode;
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(json);
}
diff --git a/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs b/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs
index 9245926..7c256c7 100644
--- a/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs
+++ b/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs
@@ -27,7 +27,7 @@ public static class ScalarUiConfiguration