Skip to content

Commit

Permalink
remove gateway service #9
Browse files Browse the repository at this point in the history
  • Loading branch information
thangchung committed Aug 11, 2018
1 parent a6255d8 commit f702797
Show file tree
Hide file tree
Showing 47 changed files with 61 additions and 1,312 deletions.
13 changes: 3 additions & 10 deletions coolstore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VND.Fw.Utils", "src\framewo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VND.Fw.Infrastructure.EfCore", "src\framework\VND.FW.Infrastructure.EfCore\VND.Fw.Infrastructure.EfCore.csproj", "{E7EB14A0-E2D3-40F1-BBA8-A9ACBBF674C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VND.CoolStore.Services.ApiGateway", "src\services\gateway\VND.CoolStore.Services.ApiGateway.csproj", "{C4722C4F-DBD3-4101-A99A-88ABC10912E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VND.Fw.Infrastructure.EfCore.SqlServer", "src\framework\VND.FW.Infrastructure.EfCore.SqlServer\VND.Fw.Infrastructure.EfCore.SqlServer.csproj", "{B73ADF43-63AF-4226-8A48-9E3B965C78D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VND.Fw.Infrastructure.AspNetCore.CleanArch", "src\framework\VND.Fw.Infrastructure.AspNetCore.CleanArch\VND.Fw.Infrastructure.AspNetCore.CleanArch.csproj", "{2C051E4E-5C60-4801-8735-A17F47573A88}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VND.Fw.Infrastructure.AspNetCore.CleanArch", "src\framework\VND.Fw.Infrastructure.AspNetCore.CleanArch\VND.Fw.Infrastructure.AspNetCore.CleanArch.csproj", "{2C051E4E-5C60-4801-8735-A17F47573A88}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VND.Fw.Infrastructure.AspNetCore.Miniservice", "src\framework\VND.Fw.Infrastructure.AspNetCore.Miniservice\VND.Fw.Infrastructure.AspNetCore.Miniservice.csproj", "{944AEFDD-0D85-4DAE-8FDF-370C508D5C9E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VND.Fw.Infrastructure.AspNetCore.Miniservice", "src\framework\VND.Fw.Infrastructure.AspNetCore.Miniservice\VND.Fw.Infrastructure.AspNetCore.Miniservice.csproj", "{944AEFDD-0D85-4DAE-8FDF-370C508D5C9E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VND.Fw.Infrastructure.AspNetCore.OpenApi", "src\framework\VND.Fw.Infrastructure.AspNetCore.OpenApi\VND.Fw.Infrastructure.AspNetCore.OpenApi.csproj", "{E230E18E-D8CD-4877-A691-E6BFBF82F686}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VND.Fw.Infrastructure.AspNetCore.OpenApi", "src\framework\VND.Fw.Infrastructure.AspNetCore.OpenApi\VND.Fw.Infrastructure.AspNetCore.OpenApi.csproj", "{E230E18E-D8CD-4877-A691-E6BFBF82F686}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -90,10 +88,6 @@ Global
{E7EB14A0-E2D3-40F1-BBA8-A9ACBBF674C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7EB14A0-E2D3-40F1-BBA8-A9ACBBF674C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7EB14A0-E2D3-40F1-BBA8-A9ACBBF674C9}.Release|Any CPU.Build.0 = Release|Any CPU
{C4722C4F-DBD3-4101-A99A-88ABC10912E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4722C4F-DBD3-4101-A99A-88ABC10912E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4722C4F-DBD3-4101-A99A-88ABC10912E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4722C4F-DBD3-4101-A99A-88ABC10912E3}.Release|Any CPU.Build.0 = Release|Any CPU
{B73ADF43-63AF-4226-8A48-9E3B965C78D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B73ADF43-63AF-4226-8A48-9E3B965C78D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B73ADF43-63AF-4226-8A48-9E3B965C78D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -125,7 +119,6 @@ Global
{7F00368D-8734-4429-B4BE-F833E7AAFFC5} = {368570BE-6D1B-451B-9C04-FD610C0E81B8}
{45A63B09-7BF7-4886-8A31-52148EF8B59A} = {368570BE-6D1B-451B-9C04-FD610C0E81B8}
{E7EB14A0-E2D3-40F1-BBA8-A9ACBBF674C9} = {368570BE-6D1B-451B-9C04-FD610C0E81B8}
{C4722C4F-DBD3-4101-A99A-88ABC10912E3} = {A0F90A99-CAD3-491F-9079-D1680D659A9B}
{B73ADF43-63AF-4226-8A48-9E3B965C78D6} = {368570BE-6D1B-451B-9C04-FD610C0E81B8}
{2C051E4E-5C60-4801-8735-A17F47573A88} = {368570BE-6D1B-451B-9C04-FD610C0E81B8}
{944AEFDD-0D85-4DAE-8FDF-370C508D5C9E} = {368570BE-6D1B-451B-9C04-FD610C0E81B8}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using VND.Fw.Infrastructure.AspNetCore.Miniservice;

namespace VND.FW.Infrastructure.AspNetCore.Miniservice
namespace VND.Fw.Infrastructure.AspNetCore.Miniservice.ConfigureApplications
{
public class AuthNConfigureApplication : IConfigureApplication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public void Configure(IApplicationBuilder app)
var basePath = config.GetBasePath();
var currentHostUri = config.GetExternalCurrentHostUri();

if (config.GetValue("EnableOpenApi", false))
if (config.GetValue("OpenApi:Enabled", false))
{
app.UseSwagger();
}

if (config.GetValue("EnableOpenApiUi", false))
if (config.GetValue("OpenApi:EnabledUI", false))
{
app.UseSwaggerUI(
c =>
Expand Down Expand Up @@ -52,4 +52,4 @@ public void Configure(IApplicationBuilder app)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
Expand All @@ -19,8 +20,15 @@ public void Configure(IServiceCollection services)
var config = svcProvider.GetRequiredService<IConfiguration>();
var serviceParams = svcProvider.GetRequiredService<ServiceParams>();

if (config.GetValue("EnableOpenApi", false))
if (config.GetSection("OpenApi") == null)
{
throw new Exception("Please add OpenApi configuration or disabled OpenAPI.");
}

if (config.GetValue("OpenApi:Enabled", false))
{
services.Configure<OpenApiOptions>(config.GetSection("OpenApi"));

services.AddSwaggerGen(c =>
{
var provider = services.BuildServiceProvider().GetRequiredService<IApiVersionDescriptionProvider>();
Expand All @@ -29,7 +37,7 @@ public void Configure(IServiceCollection services)
foreach (var description in provider.ApiVersionDescriptions)
{
c.SwaggerDoc(description.GroupName, CreateInfoForApiVersion(description));
c.SwaggerDoc(description.GroupName, CreateInfoForApiVersion(config, description));
}
// c.IncludeXmlComments (XmlCommentsFilePath);
Expand All @@ -53,7 +61,7 @@ public void Configure(IServiceCollection services)
c.OperationFilter<SecurityRequirementsOperationFilter>();
}
c.OperationFilter<SwaggerDefaultValuesOperationFilter>();
c.OperationFilter<DefaultValuesOperationFilter>();
c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
});
}
Expand All @@ -64,28 +72,23 @@ private static string GetExternalAuthUri(IConfiguration config)
return config.GetExternalHostUri("Auth");
}

/// <summary>
/// TODO: refactoring to Options
/// </summary>
/// <param name="description"></param>
/// <returns></returns>
private static Info CreateInfoForApiVersion(ApiVersionDescription description)
private static Info CreateInfoForApiVersion(IConfiguration config, ApiVersionDescription description)
{
var info = new Info()
{
Title = $"API {description.ApiVersion}",
Title = $"{config.GetValue("OpenApi:Title", "API")} {description.ApiVersion}",
Version = description.ApiVersion.ToString(),
Description = "An application with Swagger, Swashbuckle, and API versioning.",
Description = config.GetValue("OpenApi:Description", "An application with Swagger, Swashbuckle, and API versioning."),
Contact = new Contact()
{
Name = "VND",
Email = "vietnam.devs.group@gmail.com"
Name = config.GetValue("OpenApi:ContactName", "Vietnam Devs"),
Email = config.GetValue("OpenApi:ContactEmail", "vietnam.devs.group@gmail.com")
},
TermsOfService = "Shareware",
TermsOfService = config.GetValue("OpenApi:TermOfService", "Shareware"),
License = new License()
{
Name = "MIT",
Url = "https://opensource.org/licenses/MIT"
Name = config.GetValue("OpenApi:LicenseName", "MIT"),
Url = config.GetValue("OpenApi:LicenseUrl", "https://opensource.org/licenses/MIT")
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace VND.Fw.Infrastructure.AspNetCore.OpenApi
/// This <see cref="IOperationFilter" /> is only required due to bugs in the <see cref="SwaggerGenerator" />.
/// Once they are fixed and published, this class can be removed.
/// </remarks>
public class SwaggerDefaultValuesOperationFilter : IOperationFilter
public class DefaultValuesOperationFilter : IOperationFilter
{
/// <summary>
/// Applies the filter to the specified operation using the given context.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace VND.Fw.Infrastructure.AspNetCore.OpenApi
{
public class OpenApiOptions
{
public string Title { get; set; } = "API";
public string Description { get; set; } = "An application with Swagger, Swashbuckle, and API versioning.";
public string ContactName { get; set; } = "Vietnam Devs";
public string ContactEmail { get; set; } = "vietnam.devs.group@gmail.com";
public string TermOfService { get; set; } = "Shareware";
public string LicenseName { get; set; } = "MIT";
public string LicenseUrl { get; set; } = "https://opensource.org/licenses/MIT";
}
}

This file was deleted.

9 changes: 5 additions & 4 deletions src/services/cart/Extensions/CartExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using VND.CoolStore.Services.Cart.Domain;
using VND.CoolStore.Services.Cart.Dtos;

namespace VND.CoolStore.Services.Cart.Domain
namespace VND.CoolStore.Services.Cart.Extensions
{
public static class CartExtensions
{
public static CartDto ToDto(this Cart cart)
public static CartDto ToDto(this Domain.Cart cart)
{
return new CartDto
{
Expand All @@ -29,11 +30,11 @@ public static CartDto ToDto(this Cart cart)
};
}

public static async Task<Cart> InitCart(this Cart cart, ICatalogGateway catalogGateway, bool isPopulatePrice = false)
public static async Task<Domain.Cart> InitCart(this Domain.Cart cart, ICatalogGateway catalogGateway, bool isPopulatePrice = false)
{
if (cart == null)
{
cart = new Cart();
cart = new Domain.Cart();
}

if (isPopulatePrice == false)
Expand Down
6 changes: 4 additions & 2 deletions src/services/cart/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"API_VERSION": "1.0",
"SERVICE_VERSION": "0.0.1",
"EnableOpenApi": true,
"EnableOpenApiUi": true,
"EnableAuthN": true,
"ConnectionStrings": {
"mssqldb": "Server=tcp:{0},{1};Database={2};User Id={3};Password={4};"
Expand Down Expand Up @@ -42,6 +40,10 @@
}
}
},
"OpenApi": {
"Enabled": true,
"EnabledUI": true
},
"Logging": {
"IncludeScopes": false,
"Debug": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using System.Threading.Tasks;
using VND.CoolStore.Services.Cart.Domain;
using VND.CoolStore.Services.Cart.Extensions;
using VND.CoolStore.Services.Cart.v1.Extensions;
using VND.Fw.Domain;
using VND.Fw.Infrastructure.AspNetCore.CleanArch;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using VND.CoolStore.Services.Cart.Domain;
using VND.CoolStore.Services.Cart.Extensions;
using VND.CoolStore.Services.Cart.v1.Extensions;
using VND.CoolStore.Services.Cart.v1.Services;
using VND.Fw.Domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using VND.CoolStore.Services.Cart.Domain;
using VND.CoolStore.Services.Cart.Extensions;
using VND.CoolStore.Services.Cart.v1.Services;
using VND.Fw.Domain;
using VND.Fw.Infrastructure.AspNetCore.CleanArch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
using VND.CoolStore.Services.Cart.Domain;
using VND.CoolStore.Services.Cart.Extensions;
using VND.CoolStore.Services.Cart.v1.Extensions;
using VND.CoolStore.Services.Cart.v1.Services;
using VND.Fw.Domain;
Expand Down
1 change: 0 additions & 1 deletion src/services/cart/v2/CartController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Microsoft.AspNetCore.Mvc;
using VND.Fw.Infrastructure.AspNetCore;
using VND.FW.Infrastructure.AspNetCore;

namespace VND.CoolStore.Services.Cart.v2
{
Expand Down
21 changes: 0 additions & 21 deletions src/services/gateway/Dockerfile

This file was deleted.

20 changes: 0 additions & 20 deletions src/services/gateway/Infrastructure/Service/ICartService.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/services/gateway/Infrastructure/Service/ICatalogService.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/services/gateway/Infrastructure/Service/IInventoryService.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/services/gateway/Infrastructure/Service/IRatingService.cs

This file was deleted.

0 comments on commit f702797

Please sign in to comment.