Skip to content

Commit

Permalink
Merge pull request #52 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
Update config
  • Loading branch information
Ali-YousefiTelori authored Feb 1, 2024
2 parents b531657 + 10c4a54 commit d27f84b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using EasyMicroservices.TemplateGeneratorMicroservice.WebApi.Controllers;
using Identity.GeneratedServices;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using TemplateGenerators.GeneratedServices;
using Xunit;
Expand All @@ -31,20 +32,24 @@ public static async Task<IServiceProvider> StartAsync()
{
try
{
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
await Semaphore.WaitAsync();
if (DefaultServiceProvider != null)
return DefaultServiceProvider;
var app = Program.CreateBuilder(null);
UnitOfWork.MapperTypeAssembly = typeof(ItemTypeDatabaseLogic);
string authBaseUrl = $"http://localhost:{2007}";
string generatorBaseUrl = $"http://localhost:{1050}";
string generatorBaseUrl = config.GetSection("Urls").Get<string>().Replace("*", "localhost");
string authBaseUrl = config.GetSection("ServiceAddresses").GetChildren().FirstOrDefault(x=>x.GetValue<string>("Name") == "Authentication").GetValue<string>("Address");
string identityBaseUrl = config.GetSection("ServiceAddresses").GetChildren().FirstOrDefault(x=>x.GetValue<string>("Name") == "Identity").GetValue<string>("Address");
app.Services.AddSingleton(s => new HttpClient());
app.Services.AddTransient(s => new AuthenticationClient(authBaseUrl, s.GetService<HttpClient>()));
app.Services.AddTransient(s => new NoParentFormItemClient(generatorBaseUrl, s.GetService<HttpClient>()));
app.Services.AddTransient(s => new EventClient(generatorBaseUrl, s.GetService<HttpClient>()));
app.Services.AddTransient(s => new ActionClient(generatorBaseUrl, s.GetService<HttpClient>()));
app.Services.AddMvc().AddApplicationPart(typeof(FormController).Assembly);

var build = await app.BuildWithUseCors<TemplateGeneratorContext>(default, true);
build.MapControllers();
var scope = build.Services.CreateScope();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"Name": "Content",
"Address": "http://localhost:2003",
"Databases": null
},
{
"Name": "Identity",
"Address": "http://localhost:2007",
"Databases": null
}
],
"Authorization": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"Name": "Content",
"Address": "http://localhost:2003",
"Databases": null
},
{
"Name": "Identity",
"Address": "http://localhost:2007",
"Databases": null
}
],
"Authorization": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"Name": "Content",
"Address": "http://localhost:2003",
"Databases": null
},
{
"Name": "Identity",
"Address": "http://localhost:2007",
"Databases": null
}
],
"Authorization": {
Expand Down

0 comments on commit d27f84b

Please sign in to comment.