(refactor): reimplementing docker compose

This commit is contained in:
Maksym Sadovnychyy 2022-09-18 18:52:39 +02:00
parent 750263d466
commit 4b858008a9
34 changed files with 799 additions and 653 deletions

3
.gitignore vendored
View File

@ -230,3 +230,6 @@ _Pvt_Extensions
# FAKE - F# Make # FAKE - F# Make
.fake/ .fake/
# Custom
webapi/docker-compose

View File

@ -10,7 +10,7 @@
}, },
{ {
"locale": 2, "locale": 2,
"slug": "predefinit", "slug": "predefinita",
"text": "Categoria predefinita" "text": "Categoria predefinita"
} }
] ]

View File

@ -23,7 +23,3 @@
**/values.dev.yaml **/values.dev.yaml
LICENSE LICENSE
README.md README.md
**/node_modules
**/npm-debug.log
build

View File

@ -7,7 +7,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Extensions\Extensions.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -7,9 +7,11 @@ using System.Threading.Tasks;
namespace Core.Enumerations { namespace Core.Enumerations {
public class Errors : Enumeration { public class Errors : Enumeration {
public static Errors NullOrWhiteSpace = new(0, "is null or white space"); public static Errors Generic = new(0, "generic error occured");
public static Errors WrongOrNotManaged = new(1, "is wrong or not managed");
public static Errors NullOrEmpty = new(2, "is null or empty"); public static Errors NullOrWhiteSpace = new(1, "is null or white space");
public static Errors WrongOrNotManaged = new(2, "is wrong or not managed");
public static Errors NullOrEmpty = new(3, "is null or empty");
private Errors(int id, string displayName) : base(id, displayName) { } private Errors(int id, string displayName) : base(id, displayName) { }
} }

View File

@ -0,0 +1,42 @@
using Core.Enumerations;
using ExtensionMethods;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Net;
namespace Core.Middlewares {
/// <summary>
/// https://jasonwatmore.com/post/2022/01/17/net-6-global-error-handler-tutorial-with-example
/// </summary>
public class ErrorHandlerMiddleware {
private readonly ILogger<ErrorHandlerMiddleware> _logger;
private readonly RequestDelegate _next;
public ErrorHandlerMiddleware(
ILogger<ErrorHandlerMiddleware> logger,
RequestDelegate next) {
_logger = logger;
_next = next;
}
public async Task Invoke(HttpContext context) {
try {
await _next(context);
}
catch (Exception ex) {
_logger.LogError(ex, "Unhandled error");
var response = context.Response;
response.ContentType = "application/json";
response.StatusCode = (int)HttpStatusCode.InternalServerError;
await response.WriteAsync(new ProblemDetails {
Title = Errors.Generic.Name,
Detail = $"{Errors.Generic.Id}"
}.ToJson());
}
}
}
}

View File

@ -12,7 +12,7 @@ namespace DataProviders.Buckets {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public class SpecificBucketDataProviderBase : BucketDataProviderBase { public abstract class SpecificBucketDataProviderBase : BucketDataProviderBase {
private readonly string _bucketName; private readonly string _bucketName;

View File

@ -0,0 +1,22 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["ReverseProxy/ReverseProxy.csproj", "ReverseProxy/"]
RUN dotnet restore "ReverseProxy/ReverseProxy.csproj"
COPY . .
WORKDIR "/src/ReverseProxy"
RUN dotnet build "ReverseProxy.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ReverseProxy.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ReverseProxy.dll"]

View File

@ -1,4 +1,4 @@
{ {
"iisSettings": { "iisSettings": {
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
@ -10,12 +10,12 @@
"profiles": { "profiles": {
"ReverseProxy": { "ReverseProxy": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"applicationUrl": "https://localhost:7174;http://localhost:5178",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} },
"applicationUrl": "https://localhost:7174;http://localhost:5178",
"dotnetRunMessages": true
}, },
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
@ -23,6 +23,13 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true,
"useSSL": false
} }
} }
} }

View File

@ -4,9 +4,13 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>a3a6c5ea-054e-4e38-b7a4-800796fa0dd3</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="Yarp.ReverseProxy" Version="1.1.0" /> <PackageReference Include="Yarp.ReverseProxy" Version="1.1.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -25,6 +25,12 @@
] ]
}, },
"route3": { "route3": {
"ClusterId": "cluster1",
"Match": {
"Path": "swagger/{**catchall}"
}
},
"route4": {
"ClusterId": "cluster2", "ClusterId": "cluster2",
"Match": { "Match": {
"Path": "{**catchall}" "Path": "{**catchall}"
@ -35,7 +41,7 @@
"cluster1": { "cluster1": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:7151/" "Address": "http://weatherforecast:5133/"
} }
} }
}, },

View File

@ -15,8 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj",
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataProviders", "DataProviders\DataProviders.csproj", "{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataProviders", "DataProviders\DataProviders.csproj", "{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}"
EndProject EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{38A28E4B-319A-44B0-AA9B-54F3F0362317}"
EndProject
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "ClientApp", "ClientApp\ClientApp.njsproj", "{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}" Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "ClientApp", "ClientApp\ClientApp.njsproj", "{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extensions", "Extensions\Extensions.csproj", "{94A44D75-4AE2-4F1A-A7E9-821710B19F93}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extensions", "Extensions\Extensions.csproj", "{94A44D75-4AE2-4F1A-A7E9-821710B19F93}"
@ -33,6 +31,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FileSecurityService", "Serv
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReverseProxy", "ReverseProxy\ReverseProxy.csproj", "{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReverseProxy", "ReverseProxy\ReverseProxy.csproj", "{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}"
EndProject EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -59,10 +59,6 @@ Global
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.Build.0 = Release|Any CPU {13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.Build.0 = Release|Any CPU
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Release|Any CPU.Build.0 = Release|Any CPU
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.Build.0 = Debug|Any CPU {8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Release|Any CPU.ActiveCfg = Release|Any CPU {8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -91,6 +87,10 @@ Global
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU {281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU {281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.Build.0 = Release|Any CPU {281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.Build.0 = Release|Any CPU
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -6,15 +6,15 @@ using Microsoft.AspNetCore.Mvc;
using WeatherForecast.Models.Requests; using WeatherForecast.Models.Requests;
using WeatherForecast.Services; using WeatherForecast.Services;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[AllowAnonymous] [AllowAnonymous]
[ApiController] [ApiController]
[Route("api/[controller]")] [Route("api/[controller]")]
public class AuthenticationController : ControllerBase { public class AuthenticationController : ControllerBase {
private readonly IAuthenticationService _authenticationService; private readonly IAuthenticationService _authenticationService;
@ -39,5 +39,5 @@ namespace WeatherForecast.Controllers {
var result = _authenticationService.Post(siteId, requestData); var result = _authenticationService.Post(siteId, requestData);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -6,16 +6,15 @@ using DomainResults.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
using WeatherForecast.Models.Requests; using WeatherForecast.Models.Requests;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary>
/// <summary> ///
/// /// </summary>
/// </summary> [Authorize(Policy = "")]
[Authorize] [ApiController]
[ApiController] [Route("api/[controller]")]
[Route("api/[controller]")] public class BlogItemController : ControllerBase {
public class BlogItemController : ControllerBase {
private readonly IBlogItemService _blogItemService; private readonly IBlogItemService _blogItemService;
@ -57,6 +56,7 @@ namespace WeatherForecast.Controllers {
/// <param name="siteId"></param> /// <param name="siteId"></param>
/// <param name="slug"></param> /// <param name="slug"></param>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous]
[HttpGet("{siteId}")] [HttpGet("{siteId}")]
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) { public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
var result = _blogItemService.GetSlug(siteId, slug); var result = _blogItemService.GetSlug(siteId, slug);
@ -87,5 +87,5 @@ namespace WeatherForecast.Controllers {
var result = _blogItemService.Delete(siteId, blogId); var result = _blogItemService.Delete(siteId, blogId);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -10,7 +10,7 @@ namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[AllowAnonymous] [Authorize(Policy = "")]
[ApiController] [ApiController]
[Route("api/[controller]")] [Route("api/[controller]")]
public class BlogItemsController : ControllerBase { public class BlogItemsController : ControllerBase {
@ -37,6 +37,7 @@ public class BlogItemsController : ControllerBase {
/// <param name="itemsPerPage"></param> /// <param name="itemsPerPage"></param>
/// <param name="locale"></param> /// <param name="locale"></param>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous]
[HttpGet("{siteId}")] [HttpGet("{siteId}")]
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale) { public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale) {
var result = _blogItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText); var result = _blogItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText);

View File

@ -6,15 +6,15 @@ using DomainResults.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
using WeatherForecast.Models.Requests; using WeatherForecast.Models.Requests;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[ApiController] [ApiController]
[Route("api/[controller]")] [Route("api/[controller]")]
public class CategoryItemController : ControllerBase { public class CategoryItemController : ControllerBase {
private readonly ICategoryItemService _categoryItemService; private readonly ICategoryItemService _categoryItemService;
@ -87,5 +87,5 @@ namespace WeatherForecast.Controllers {
var result = _categoryItemService.Delete(siteId, categoryId); var result = _categoryItemService.Delete(siteId, categoryId);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -5,15 +5,15 @@ using DomainResults.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[ApiController] [ApiController]
[Route("api/[controller]")] [Route("api/[controller]")]
public class CategoryItemsController : ControllerBase { public class CategoryItemsController : ControllerBase {
private readonly ICategoryItemsService _categoryItemsService; private readonly ICategoryItemsService _categoryItemsService;
@ -50,5 +50,5 @@ namespace WeatherForecast.Controllers {
var result = _categoryItemsService.Delete(siteId); var result = _categoryItemsService.Delete(siteId);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -4,15 +4,15 @@ using Microsoft.AspNetCore.Mvc;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using WeatherForecast.Services; using WeatherForecast.Services;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[AllowAnonymous] [AllowAnonymous]
[Route("api/[controller]")] [Route("api/[controller]")]
public class FileController : Controller { public class FileController : Controller {
private readonly IFileService _fileService; private readonly IFileService _fileService;
@ -71,5 +71,5 @@ namespace WeatherForecast.Controllers {
var result = _fileService.Delete(siteId, userId, fileId); var result = _fileService.Delete(siteId, userId, fileId);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -3,15 +3,15 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[AllowAnonymous] [AllowAnonymous]
[Route("api/[controller]")] [Route("api/[controller]")]
public class FilesController : Controller { public class FilesController : Controller {
private readonly IFilesService _filesService; private readonly IFilesService _filesService;
@ -50,5 +50,5 @@ namespace WeatherForecast.Controllers {
var result = _filesService.Delete(siteId, userId); var result = _filesService.Delete(siteId, userId);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -4,15 +4,15 @@ using Microsoft.AspNetCore.Authorization;
using WeatherForecast.Services; using WeatherForecast.Services;
using DomainResults.Mvc; using DomainResults.Mvc;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[AllowAnonymous] [AllowAnonymous]
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class ImageController : ControllerBase { public class ImageController : ControllerBase {
private readonly IImageService _imageService; private readonly IImageService _imageService;
@ -48,5 +48,4 @@ namespace WeatherForecast.Controllers {
}; };
} }
}
} }

View File

@ -5,14 +5,15 @@ using Microsoft.AspNetCore.Mvc;
using WeatherForecast.Models.Requests; using WeatherForecast.Models.Requests;
using WeatherForecast.Services; using WeatherForecast.Services;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary>
/// /// <summary>
/// </summary> ///
[Authorize] /// </summary>
[Route("api/[controller]")] [Authorize]
[ApiController] [Route("api/[controller]")]
public class PasswordController : ControllerBase { [ApiController]
public class PasswordController : ControllerBase {
private readonly IPasswordService _passwordService; private readonly IPasswordService _passwordService;
@ -34,5 +35,5 @@ namespace WeatherForecast.Controllers {
var result = _passwordService.Post(siteId, userId, requestData); var result = _passwordService.Post(siteId, userId, requestData);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -6,16 +6,16 @@ using DomainResults.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
using WeatherForecast.Models.Requests; using WeatherForecast.Models.Requests;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[AllowAnonymous] [AllowAnonymous]
[Route("api/[controller]")] [Route("api/[controller]")]
public class ShopCartItemController : ControllerBase { public class ShopCartItemController : ControllerBase {
private readonly IShopCartItemService _shopCartItemService; private readonly IShopCartItemService _shopCartItemService;
@ -79,5 +79,5 @@ namespace WeatherForecast.Controllers {
var result = _shopCartItemService.Delete(siteId, userId, sku); var result = _shopCartItemService.Delete(siteId, userId, sku);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -5,16 +5,16 @@ using DomainResults.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[AllowAnonymous] [AllowAnonymous]
[Route("api/[controller]")] [Route("api/[controller]")]
public class ShopCartItemsController : ControllerBase { public class ShopCartItemsController : ControllerBase {
private readonly IShopCartItemsService _shopCartItemsService; private readonly IShopCartItemsService _shopCartItemsService;
@ -50,5 +50,4 @@ namespace WeatherForecast.Controllers {
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -6,15 +6,15 @@ using DomainResults.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
using WeatherForecast.Models.Requests; using WeatherForecast.Models.Requests;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[ApiController] [ApiController]
[Route("api/[controller]")] [Route("api/[controller]")]
public class ShopItemController : ControllerBase { public class ShopItemController : ControllerBase {
private readonly IShopItemService _shopItemService; private readonly IShopItemService _shopItemService;
@ -90,5 +90,5 @@ namespace WeatherForecast.Controllers {
var result = _shopItemService.Delete(siteId, sku); var result = _shopItemService.Delete(siteId, sku);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -5,15 +5,15 @@ using DomainResults.Mvc;
using WeatherForecast.Services; using WeatherForecast.Services;
namespace WeatherForecast.Controllers { namespace WeatherForecast.Controllers;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
[Authorize] [Authorize]
[ApiController] [ApiController]
[Route("api/[controller]")] [Route("api/[controller]")]
public class ShopItemsController : ControllerBase { public class ShopItemsController : ControllerBase {
private readonly IShopItemsService _shopItemsService; private readonly IShopItemsService _shopItemsService;
@ -53,5 +53,4 @@ namespace WeatherForecast.Controllers {
var result = _shopItemsService.Delete(siteId); var result = _shopItemsService.Delete(siteId);
return result.ToActionResult(); return result.ToActionResult();
} }
}
} }

View File

@ -8,7 +8,13 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src WORKDIR /src
COPY ["WeatherForecast/WeatherForecast.csproj", "WeatherForecast/"] COPY ["WeatherForecast/WeatherForecast.csproj", "WeatherForecast/"]
COPY ["Services/FileSecurityService/FileSecurityService.csproj", "Services/FileSecurityService/"]
COPY ["Extensions/Extensions.csproj", "Extensions/"]
COPY ["Core/Core.csproj", "Core/"] COPY ["Core/Core.csproj", "Core/"]
COPY ["Services/ImageProvider/ImageProvider.csproj", "Services/ImageProvider/"]
COPY ["DataProviders/DataProviders.csproj", "DataProviders/"]
COPY ["Services/JWTService/JWTService.csproj", "Services/JWTService/"]
COPY ["Services/HashService/HashService.csproj", "Services/HashService/"]
RUN dotnet restore "WeatherForecast/WeatherForecast.csproj" RUN dotnet restore "WeatherForecast/WeatherForecast.csproj"
COPY . . COPY . .
WORKDIR "/src/WeatherForecast" WORKDIR "/src/WeatherForecast"

View File

@ -11,7 +11,7 @@
"profiles": { "profiles": {
"WeatherForecast": { "WeatherForecast": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": false,
"launchUrl": "swagger", "launchUrl": "swagger",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
@ -21,7 +21,7 @@
}, },
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true, "launchBrowser": false,
"launchUrl": "swagger", "launchUrl": "swagger",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
@ -30,12 +30,9 @@
"Docker": { "Docker": {
"commandName": "Docker", "commandName": "Docker",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"publishAllPorts": true, "publishAllPorts": true,
"useSSL": true "useSSL": false
} }
} }
} }

View File

@ -10,6 +10,7 @@ using FileSecurityService.Extensions;
using ImageProvider.Extensions; using ImageProvider.Extensions;
using JWTService.Extensions; using JWTService.Extensions;
using HashService.Extensions; using HashService.Extensions;
using Core.Middlewares;
namespace WeatherForecast { namespace WeatherForecast {
@ -198,6 +199,9 @@ namespace WeatherForecast {
// UseCors must be called before UseResponseCaching // UseCors must be called before UseResponseCaching
app.UseCors(MyAllowSpecificOrigins); app.UseCors(MyAllowSpecificOrigins);
// global error handler
app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseAuthentication(); app.UseAuthentication();
app.UseAuthorization(); app.UseAuthorization();

View File

@ -22,7 +22,7 @@
"Database": { "Database": {
"ConnectionString": "mongodb://localhost:27017" "ConnectionString": "mongodb://root:example@mongo:27017"
} }
} }

View File

@ -3,10 +3,10 @@
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion> <ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS> <DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>38a28e4b-319a-44b0-aa9b-54f3f0362317</ProjectGuid> <ProjectGuid>7fc6f0ba-2dcb-4b53-a3b3-61ceef42b9d0</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction> <DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl> <DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>weatherforecast</DockerServiceName> <DockerServiceName>reverseproxy</DockerServiceName>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="docker-compose.override.yml"> <None Include="docker-compose.override.yml">

View File

@ -1,12 +1,54 @@
version: '3.4' version: '3.4'
#services: networks:
# weatherforecast: my-network:
# environment: driver: "bridge"
# - ASPNETCORE_ENVIRONMENT=Development
# - ASPNETCORE_URLS=https://+:443;http://+:80 services:
# ports: reverseproxy:
# - "80" environment:
# - "443" - ASPNETCORE_ENVIRONMENT=Development
# volumes: - ASPNETCORE_URLS=https://+:7174;http://+:5178
# - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro ports:
- "7174:7174"
- "5178:5178"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
networks:
- "my-network"
weatherforecast:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:7151;http://+:5133
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
networks:
- "my-network"
mongo:
image: mongo
restart: always
ports:
- 27018:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
volumes:
- ./docker-compose/mongo/data/db:/data/db
networks:
- "my-network"
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
networks:
- "my-network"

View File

@ -1,15 +1,14 @@
version: '3.4' version: '3.4'
services: services:
clientapp: weatherforecast:
image: ${DOCKER_REGISTRY-}clientapp image: ${DOCKER_REGISTRY-}weatherforecast
build: build:
context: . context: .
dockerfile: ClientApp/Dockerfile dockerfile: WeatherForecast/Dockerfile
reverseproxy:
image: ${DOCKER_REGISTRY-}reverseproxy
build:
context: .
dockerfile: ReverseProxy/Dockerfile
#weatherforecast:
# image: ${DOCKER_REGISTRY-}weatherforecast
# build:
# context: .
# dockerfile: WeatherForecast/Dockerfile

View File

@ -0,0 +1,11 @@
{
"profiles": {
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"serviceActions": {
"weatherforecast": "StartDebugging"
}
}
}
}