Browse Source

added module dependencies and fixed project references

pull/79/head
Galip Tolga Erdem 5 years ago
parent
commit
a7bbaf7a9f
  1. 41
      services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs
  2. 62
      services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj
  3. 36
      services/basket/src/EShopOnAbp.BasketService/Program.cs

41
services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs

@ -1,5 +1,6 @@
using EShopOnAbp.BasketService.Entities; using EShopOnAbp.BasketService.Entities;
using EShopOnAbp.BasketService.Localization; using EShopOnAbp.BasketService.Localization;
using EShopOnAbp.CatalogService;
using EShopOnAbp.CatalogService.Grpc; using EShopOnAbp.CatalogService.Grpc;
using EShopOnAbp.Shared.Hosting.AspNetCore; using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Microservices; using EShopOnAbp.Shared.Hosting.Microservices;
@ -7,19 +8,32 @@ using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.AntiForgery; using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.Authorization;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Domain;
using Volo.Abp.Http.Client; using Volo.Abp.Http.Client;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling; using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization; using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace EShopOnAbp.BasketService namespace EShopOnAbp.BasketService
{ {
[DependsOn( [DependsOn(typeof(AbpAuthorizationModule),
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAutoMapperModule),
typeof(AbpCachingModule),
typeof(AbpDddApplicationModule),
typeof(AbpDddDomainModule),
typeof(AbpValidationModule),
typeof(CatalogServiceHttpApiClientModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)] )]
public class BasketServiceModule : AbpModule public class BasketServiceModule : AbpModule
{ {
@ -37,6 +51,8 @@ namespace EShopOnAbp.BasketService
ConfigureLocalization(); ConfigureLocalization();
ConfigureHttpApiProxy(context); ConfigureHttpApiProxy(context);
ConfigureAuthentication(context, configuration); ConfigureAuthentication(context, configuration);
ConfigureSwagger(context, configuration);
ConfigureAutoApiControllers();
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -70,11 +86,9 @@ namespace EShopOnAbp.BasketService
app.UseUnitOfWork(); app.UseUnitOfWork();
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();
} }
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
{ {
JwtBearerConfigurationHelper.Configure(context, "BasketService");
SwaggerWithAuthConfigurationHelper.Configure( SwaggerWithAuthConfigurationHelper.Configure(
context: context, context: context,
authority: configuration["AuthServer:Authority"], authority: configuration["AuthServer:Authority"],
@ -85,6 +99,11 @@ namespace EShopOnAbp.BasketService
}, },
apiTitle: "Basket Service API" apiTitle: "Basket Service API"
); );
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
JwtBearerConfigurationHelper.Configure(context, "BasketService");
context.Services.AddCors(options => context.Services.AddCors(options =>
{ {
@ -108,10 +127,18 @@ namespace EShopOnAbp.BasketService
Configure<AbpAntiForgeryOptions>(options => { options.AutoValidate = false; }); Configure<AbpAntiForgeryOptions>(options => { options.AutoValidate = false; });
} }
private void ConfigureAutoApiControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(BasketServiceModule).Assembly);
});
}
private void ConfigureHttpApiProxy(ServiceConfigurationContext context) private void ConfigureHttpApiProxy(ServiceConfigurationContext context)
{ {
context.Services.AddStaticHttpClientProxies( context.Services.AddStaticHttpClientProxies(
typeof(BasketServiceApplicationContractsModule).Assembly, typeof(BasketServiceModule).Assembly,
RemoteServiceName RemoteServiceName
); );
} }
@ -132,7 +159,7 @@ namespace EShopOnAbp.BasketService
{ {
Configure<AbpAutoMapperOptions>(options => Configure<AbpAutoMapperOptions>(options =>
{ {
options.AddMaps<BasketServiceApplicationModule>(); options.AddMaps<BasketServiceModule>();
}); });
} }

62
services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj

@ -1,67 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<!-- DOMAIN SHARED -->
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.Validation" Version="5.1.2" /> <PackageReference Include="Google.Protobuf" Version="3.19.3" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.42.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.0" />
<ProjectReference Include="..\..\..\ordering\src\EShopOnAbp.OrderingService.Domain.Shared\EShopOnAbp.OrderingService.Domain.Shared.csproj" />
</ItemGroup> <PackageReference Include="Volo.Abp.Authorization" Version="5.1.2"/>
<ItemGroup> <PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="5.1.2" />
<EmbeddedResource Include="Localization\BasketService\*.json" /> <PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.2" />
<Content Remove="Localization\BasketService\*.json" />
</ItemGroup>
<!-- DOMAIN -->
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.BasketService.Domain.Shared\EShopOnAbp.BasketService.Domain.Shared.csproj" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Caching" Version="5.1.2" /> <PackageReference Include="Volo.Abp.Caching" Version="5.1.2" />
</ItemGroup> <PackageReference Include="Volo.Abp.Ddd.Domain" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="5.1.2" />
<!-- APPLICATION CONTRACTS --> <PackageReference Include="Volo.Abp.Validation" Version="5.1.2" />
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.BasketService.Domain.Shared\EShopOnAbp.BasketService.Domain.Shared.csproj" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Authorization" Version="5.1.2" />
</ItemGroup> </ItemGroup>
<!-- APPLICATION --> <ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="5.1.2" />
<PackageReference Include="Google.Protobuf" Version="3.19.3" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.42.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<Protobuf Include="..\..\..\catalog\src\EShopOnAbp.CatalogService.Application.Contracts\Protos\product.proto" GrpcServices="Client" />
<ProjectReference Include="..\EShopOnAbp.BasketService.Domain\EShopOnAbp.BasketService.Domain.csproj" />
<ProjectReference Include="..\EShopOnAbp.BasketService.Application.Contracts\EShopOnAbp.BasketService.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\catalog\src\EShopOnAbp.CatalogService.HttpApi.Client\EShopOnAbp.CatalogService.HttpApi.Client.csproj" /> <ProjectReference Include="..\..\..\catalog\src\EShopOnAbp.CatalogService.HttpApi.Client\EShopOnAbp.CatalogService.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Microservices\EShopOnAbp.Shared.Hosting.Microservices.csproj" />
</ItemGroup> </ItemGroup>
<!-- HTTP API -->
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="5.1.2" /> <Protobuf Include="..\..\..\catalog\src\EShopOnAbp.CatalogService.Application.Contracts\Protos\product.proto" GrpcServices="Client" />
<ProjectReference Include="..\EShopOnAbp.BasketService.Application.Contracts\EShopOnAbp.BasketService.Application.Contracts.csproj" />
</ItemGroup> </ItemGroup>
<!-- HTTP API HOST -->
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\EShopOnAbp.BasketService.Application\EShopOnAbp.BasketService.Application.csproj" /> <EmbeddedResource Include="Localization\BasketService\*.json" />
<ProjectReference Include="..\EShopOnAbp.BasketService.HttpApi\EShopOnAbp.BasketService.HttpApi.csproj" /> <Content Remove="Localization\BasketService\*.json" />
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Microservices\EShopOnAbp.Shared.Hosting.Microservices.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Logs\**" /> <Compile Remove="Logs\**" />
<Content Remove="Logs\**" /> <Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" /> <EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" /> <None Remove="Logs\**" />
</ItemGroup> </ItemGroup>
</Project> </Project>

36
services/basket/src/EShopOnAbp.BasketService/Program.cs

@ -1,6 +1,34 @@
var builder = WebApplication.CreateBuilder(args); using EShopOnAbp.Shared.Hosting.AspNetCore;
var app = builder.Build(); using Serilog;
app.MapGet("/", () => "Hello World!"); namespace EShopOnAbp.BasketService;
app.Run(); public class Program
{
public static async Task<int> Main(string[] args)
{
var assemblyName = typeof(Program).Assembly.GetName().Name;
SerilogConfigurationHelper.Configure(assemblyName);
try
{
Log.Information($"Starting {assemblyName}.");
var app = await ApplicationBuilderHelper
.BuildApplicationAsync<BasketServiceModule>(args);
await app.InitializeApplicationAsync();
await app.RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
}
Loading…
Cancel
Save