Skip to content

Commit

Permalink
Merge pull request #10 from amirhossein18121380/fix-module-structure
Browse files Browse the repository at this point in the history
Adding the Program.cs file to each module was the issue. #2, #10
  • Loading branch information
meysamhadeli authored Jul 24, 2024
2 parents 4fe5e7f + 5688a2d commit 2a7334e
Show file tree
Hide file tree
Showing 29 changed files with 689 additions and 42 deletions.
67 changes: 35 additions & 32 deletions booking-modular-monolith-sample.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{F7A6067F-42D3-4F59-BC88-0A57A4B903F1}"
EndProject
Expand All @@ -11,7 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{34A7
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CA40C0D9-091C-4098-8F0E-FEA1C777303E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildingBlocks", "src\BuildingBlocks\BuildingBlocks.csproj", "{285E55A8-0C26-41DB-AD72-0D0557BDAE76}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildingBlocks", "src\BuildingBlocks\BuildingBlocks.csproj", "{285E55A8-0C26-41DB-AD72-0D0557BDAE76}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Booking", "Booking", "{F8725F12-8D95-4A62-9D27-84909E215D36}"
EndProject
Expand All @@ -29,41 +29,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{70395541-D3C
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0468D5FF-FA73-422F-AB68-A3900B0DB937}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flight", "src\Modules\Flight\src\Flight\Flight.csproj", "{56CE1785-AA9B-427E-AE29-492A637DDD1A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flight", "src\Modules\Flight\src\Flight\Flight.csproj", "{56CE1785-AA9B-427E-AE29-492A637DDD1A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity", "src\Modules\Identity\src\Identity\Identity.csproj", "{7A590034-D985-4BC6-82ED-83839AAB052D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Identity", "src\Modules\Identity\src\Identity\Identity.csproj", "{7A590034-D985-4BC6-82ED-83839AAB052D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Passenger", "src\Modules\Passenger\src\Passenger\Passenger.csproj", "{747845A0-25C5-4E01-A735-1B1E2ADA9554}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passenger", "src\Modules\Passenger\src\Passenger\Passenger.csproj", "{747845A0-25C5-4E01-A735-1B1E2ADA9554}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking", "src\Modules\Booking\src\Booking\Booking.csproj", "{E534AFC5-DC20-479F-8AC1-86CD28ABA682}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "src\Api\src\Api.csproj", "{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "src\Api\src\Api.csproj", "{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Booking", "src\Modules\Booking\src\Booking\Booking.csproj", "{EE98D038-5711-4049-8197-41B4C52DFEE9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CA40C0D9-091C-4098-8F0E-FEA1C777303E} = {F7A6067F-42D3-4F59-BC88-0A57A4B903F1}
{285E55A8-0C26-41DB-AD72-0D0557BDAE76} = {BD4BC863-4353-4CDF-8085-F0212A2EEA11}
{F8725F12-8D95-4A62-9D27-84909E215D36} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{4A86BE62-83F4-4CB6-94F8-A5F00304A44E} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{CB89FC18-7C55-4671-A4D6-025FF54C2741} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{E5653FEF-8BC9-4B78-AF78-10BA09A06462} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{BAB888BA-2703-4114-93C2-501EA48454E4} = {F8725F12-8D95-4A62-9D27-84909E215D36}
{2BF6ABC1-6F8C-4FE2-97DB-862669F3913F} = {4A86BE62-83F4-4CB6-94F8-A5F00304A44E}
{70395541-D3C0-4E8B-830F-E1C93926F9C8} = {CB89FC18-7C55-4671-A4D6-025FF54C2741}
{0468D5FF-FA73-422F-AB68-A3900B0DB937} = {E5653FEF-8BC9-4B78-AF78-10BA09A06462}
{56CE1785-AA9B-427E-AE29-492A637DDD1A} = {2BF6ABC1-6F8C-4FE2-97DB-862669F3913F}
{7A590034-D985-4BC6-82ED-83839AAB052D} = {70395541-D3C0-4E8B-830F-E1C93926F9C8}
{747845A0-25C5-4E01-A735-1B1E2ADA9554} = {0468D5FF-FA73-422F-AB68-A3900B0DB937}
{E534AFC5-DC20-479F-8AC1-86CD28ABA682} = {BAB888BA-2703-4114-93C2-501EA48454E4}
{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4} = {CA40C0D9-091C-4098-8F0E-FEA1C777303E}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{285E55A8-0C26-41DB-AD72-0D0557BDAE76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{285E55A8-0C26-41DB-AD72-0D0557BDAE76}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -81,13 +61,36 @@ Global
{747845A0-25C5-4E01-A735-1B1E2ADA9554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{747845A0-25C5-4E01-A735-1B1E2ADA9554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{747845A0-25C5-4E01-A735-1B1E2ADA9554}.Release|Any CPU.Build.0 = Release|Any CPU
{E534AFC5-DC20-479F-8AC1-86CD28ABA682}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E534AFC5-DC20-479F-8AC1-86CD28ABA682}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E534AFC5-DC20-479F-8AC1-86CD28ABA682}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E534AFC5-DC20-479F-8AC1-86CD28ABA682}.Release|Any CPU.Build.0 = Release|Any CPU
{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4}.Release|Any CPU.Build.0 = Release|Any CPU
{EE98D038-5711-4049-8197-41B4C52DFEE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE98D038-5711-4049-8197-41B4C52DFEE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE98D038-5711-4049-8197-41B4C52DFEE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE98D038-5711-4049-8197-41B4C52DFEE9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CA40C0D9-091C-4098-8F0E-FEA1C777303E} = {F7A6067F-42D3-4F59-BC88-0A57A4B903F1}
{285E55A8-0C26-41DB-AD72-0D0557BDAE76} = {BD4BC863-4353-4CDF-8085-F0212A2EEA11}
{F8725F12-8D95-4A62-9D27-84909E215D36} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{4A86BE62-83F4-4CB6-94F8-A5F00304A44E} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{CB89FC18-7C55-4671-A4D6-025FF54C2741} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{E5653FEF-8BC9-4B78-AF78-10BA09A06462} = {34A73111-C432-4051-ACE5-968F7ED3F634}
{BAB888BA-2703-4114-93C2-501EA48454E4} = {F8725F12-8D95-4A62-9D27-84909E215D36}
{2BF6ABC1-6F8C-4FE2-97DB-862669F3913F} = {4A86BE62-83F4-4CB6-94F8-A5F00304A44E}
{70395541-D3C0-4E8B-830F-E1C93926F9C8} = {CB89FC18-7C55-4671-A4D6-025FF54C2741}
{0468D5FF-FA73-422F-AB68-A3900B0DB937} = {E5653FEF-8BC9-4B78-AF78-10BA09A06462}
{56CE1785-AA9B-427E-AE29-492A637DDD1A} = {2BF6ABC1-6F8C-4FE2-97DB-862669F3913F}
{7A590034-D985-4BC6-82ED-83839AAB052D} = {70395541-D3C0-4E8B-830F-E1C93926F9C8}
{747845A0-25C5-4E01-A735-1B1E2ADA9554} = {0468D5FF-FA73-422F-AB68-A3900B0DB937}
{3B2CDE51-E7F9-418E-AA28-4BFD86C728F4} = {CA40C0D9-091C-4098-8F0E-FEA1C777303E}
{EE98D038-5711-4049-8197-41B4C52DFEE9} = {BAB888BA-2703-4114-93C2-501EA48454E4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A809DAA3-8F41-4B78-8F09-F03B2FB31AB5}
EndGlobalSection
EndGlobal
7 changes: 4 additions & 3 deletions src/Modules/Booking/src/Booking/Booking.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,6 +16,7 @@
<Folder Include="Data\Migrations" />
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\..\..\..\BuildingBlocks\BuildingBlocks.csproj" />
</ItemGroup>
Expand Down
71 changes: 71 additions & 0 deletions src/Modules/Booking/src/Booking/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Booking;
using BuildingBlocks.CAP;
using BuildingBlocks.Domain;
using BuildingBlocks.Exception;
using BuildingBlocks.Jwt;
using BuildingBlocks.Logging;
using BuildingBlocks.MediatR;
using BuildingBlocks.Swagger;
using BuildingBlocks.Web;
using Figgle;
using Hellang.Middleware.ProblemDetails;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;

var builder = WebApplication.CreateBuilder(args);
var configuration = builder.Configuration;
var env = builder.Environment;

var appOptions = builder.Services.GetOptions<AppOptions>("AppOptions");
Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name));

builder.AddCustomSerilog(env);
builder.Services.AddJwt();
builder.Services.AddControllers();
builder.Services.AddHttpContextAccessor();

builder.Services.AddCustomCap();
builder.Services.AddTransient<IBusPublisher, BusPublisher>();
builder.Services.AddCustomVersioning();

builder.Services.AddCustomSwagger(configuration,
typeof(BookingRoot).Assembly);

builder.Services.AddCustomProblemDetails();

builder.Services.AddBookingModules(configuration);

builder.Services.AddEasyCaching(options => { options.UseInMemory(configuration, "mem"); });

builder.Services.AddCustomMediatR(
typeof(BookingRoot).Assembly
);

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
var provider = app.Services.GetService<IApiVersionDescriptionProvider>();
app.UseCustomSwagger(provider);
}

app.UseSerilogRequestLogging();
app.UseCorrelationId();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseHttpsRedirection();

app.UseBookingModules();
app.UseProblemDetails();

app.UseEndpoints(endpoints => { endpoints.MapControllers(); });

app.MapGet("/", x => x.Response.WriteAsync(appOptions.Name));

app.Run();
31 changes: 31 additions & 0 deletions src/Modules/Booking/src/Booking/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17192",
"sslPort": 44353
}
},
"profiles": {
"Booking": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchUrl": "swagger",
"launchBrowser": true,
"applicationUrl": "https://localhost:5002;http://localhost:5003",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
8 changes: 8 additions & 0 deletions src/Modules/Booking/src/Booking/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
2 changes: 2 additions & 0 deletions src/Modules/Booking/src/Booking/appsettings.docker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
46 changes: 46 additions & 0 deletions src/Modules/Booking/src/Booking/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"AppOptions": {
"Name": "Booking-Modular-Monolith"
},
"LogOptions": {
"Level": "information",
"LogTemplate": "{Timestamp:HH:mm:ss} [{Level:u4}] {Message:lj}{NewLine}{Exception}",
"Elastic": {
"Enabled": true,
"ElasticServiceUrl": "http://localhost:9200"
},
"File": {
"Enabled": false,
"Path": "logs/logs.txt",
"Interval": "day"
},
"Sentry": {
"Enabled": false,
"Dsn": "",
"MinimumBreadcrumbLevel": "information",
"MinimumEventLevel": "error"
}
},
"ConnectionStrings": {
"Booking": "Server=.\\sqlexpress;Database=BookingDB-Monolith;Trusted_Connection=True;MultipleActiveResultSets=true",
"Flight": "Server=.\\sqlexpress;Database=FlightDB-Monolith;Trusted_Connection=True;MultipleActiveResultSets=true",
"Passenger":"Server=.\\sqlexpress;Database=PassengerDB-Monolith;Trusted_Connection=True;MultipleActiveResultSets=true",
"Identity": "Server=.\\sqlexpress;Database=IdentityDB-Monolith;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Jwt": {
"Authority": "https://localhost:5000",
"Audience": "booking"
},
"Grpc": {
"FlightAddress": "https://localhost:5000",
"PassengerAddress": "https://localhost:5000"
},
"EventStore": {
"ConnectionString": "esdb://localhost:2113?tls=false"
},
"PersistMessageOptions": {
"Interval": 30,
"Enabled": true
},
"AllowedHosts": "*"
}
2 changes: 2 additions & 0 deletions src/Modules/Booking/src/Booking/appsettings.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
4 changes: 2 additions & 2 deletions src/Modules/Flight/src/Flight/Flight.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
73 changes: 73 additions & 0 deletions src/Modules/Flight/src/Flight/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using BuildingBlocks.CAP;
using BuildingBlocks.Domain;
using BuildingBlocks.Exception;
using BuildingBlocks.Jwt;
using BuildingBlocks.Logging;
using BuildingBlocks.MediatR;
using BuildingBlocks.Swagger;
using BuildingBlocks.Web;
using Figgle;
using Flight;
using Hellang.Middleware.ProblemDetails;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using System;

var builder = WebApplication.CreateBuilder(args);
var configuration = builder.Configuration;
var env = builder.Environment;

var appOptions = builder.Services.GetOptions<AppOptions>("AppOptions");
Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name));

builder.AddCustomSerilog(env);
builder.Services.AddJwt();
builder.Services.AddControllers();
builder.Services.AddHttpContextAccessor();

builder.Services.AddCustomCap();
builder.Services.AddTransient<IBusPublisher, BusPublisher>();
builder.Services.AddCustomVersioning();

builder.Services.AddCustomSwagger(configuration,
typeof(FlightRoot).Assembly);

builder.Services.AddCustomProblemDetails();

builder.Services.AddFlightModules(configuration);

builder.Services.AddEasyCaching(options => { options.UseInMemory(configuration, "mem"); });

builder.Services.AddCustomMediatR(
typeof(FlightRoot).Assembly
);

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
var provider = app.Services.GetService<IApiVersionDescriptionProvider>();
app.UseCustomSwagger(provider);
}

app.UseSerilogRequestLogging();
app.UseCorrelationId();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseHttpsRedirection();

app.UseFlightModules();


app.UseProblemDetails();

app.UseEndpoints(endpoints => { endpoints.MapControllers(); });

app.MapGet("/", x => x.Response.WriteAsync(appOptions.Name));

app.Run();
Loading

0 comments on commit 2a7334e

Please sign in to comment.