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.Localization;
using EShopOnAbp.CatalogService;
using EShopOnAbp.CatalogService.Grpc;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Microservices;
@ -7,19 +8,32 @@ using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Options;
using Volo.Abp;
using Volo.Abp.Application;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.Authorization;
using Volo.Abp.AutoMapper;
using Volo.Abp.Caching;
using Volo.Abp.Domain;
using Volo.Abp.Http.Client;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;
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
{
@ -37,6 +51,8 @@ namespace EShopOnAbp.BasketService
ConfigureLocalization();
ConfigureHttpApiProxy(context);
ConfigureAuthentication(context, configuration);
ConfigureSwagger(context, configuration);
ConfigureAutoApiControllers();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -70,11 +86,9 @@ namespace EShopOnAbp.BasketService
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
private void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
{
JwtBearerConfigurationHelper.Configure(context, "BasketService");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
@ -85,6 +99,11 @@ namespace EShopOnAbp.BasketService
},
apiTitle: "Basket Service API"
);
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
JwtBearerConfigurationHelper.Configure(context, "BasketService");
context.Services.AddCors(options =>
{
@ -108,10 +127,18 @@ namespace EShopOnAbp.BasketService
Configure<AbpAntiForgeryOptions>(options => { options.AutoValidate = false; });
}
private void ConfigureAutoApiControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(BasketServiceModule).Assembly);
});
}
private void ConfigureHttpApiProxy(ServiceConfigurationContext context)
{
context.Services.AddStaticHttpClientProxies(
typeof(BasketServiceApplicationContractsModule).Assembly,
typeof(BasketServiceModule).Assembly,
RemoteServiceName
);
}
@ -132,7 +159,7 @@ namespace EShopOnAbp.BasketService
{
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">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<!-- DOMAIN SHARED -->
<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" />
<ProjectReference Include="..\..\..\ordering\src\EShopOnAbp.OrderingService.Domain.Shared\EShopOnAbp.OrderingService.Domain.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization\BasketService\*.json" />
<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.Authorization" Version="5.1.2"/>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="5.1.2" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Caching" Version="5.1.2" />
</ItemGroup>
<!-- APPLICATION CONTRACTS -->
<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" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Validation" Version="5.1.2" />
</ItemGroup>
<!-- APPLICATION -->
<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" />
<ItemGroup>
<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>
<!-- HTTP API -->
<ItemGroup>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="5.1.2" />
<ProjectReference Include="..\EShopOnAbp.BasketService.Application.Contracts\EShopOnAbp.BasketService.Application.Contracts.csproj" />
<Protobuf Include="..\..\..\catalog\src\EShopOnAbp.CatalogService.Application.Contracts\Protos\product.proto" GrpcServices="Client" />
</ItemGroup>
<!-- HTTP API HOST -->
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.BasketService.Application\EShopOnAbp.BasketService.Application.csproj" />
<ProjectReference Include="..\EShopOnAbp.BasketService.HttpApi\EShopOnAbp.BasketService.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Microservices\EShopOnAbp.Shared.Hosting.Microservices.csproj" />
<EmbeddedResource Include="Localization\BasketService\*.json" />
<Content Remove="Localization\BasketService\*.json" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Logs\**" />
<Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" />
</ItemGroup>
</Project>

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

@ -1,6 +1,34 @@
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
using EShopOnAbp.Shared.Hosting.AspNetCore;
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