|
|
@ -1,13 +1,10 @@
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Reflection;
|
|
|
|
using DbContextLib;
|
|
|
|
using DbContextLib;
|
|
|
|
using DbContextLib.Identity;
|
|
|
|
using DbContextLib.Identity;
|
|
|
|
using Entities;
|
|
|
|
|
|
|
|
using HeartTrackAPI.Utils;
|
|
|
|
using HeartTrackAPI.Utils;
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.AspNetCore.Identity.UI.Services;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
|
|
|
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Versioning;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Versioning;
|
|
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
@ -39,30 +36,29 @@ public class AppBootstrap(IConfiguration configuration)
|
|
|
|
|
|
|
|
|
|
|
|
private void AddHeartTrackContextServices(IServiceCollection services)
|
|
|
|
private void AddHeartTrackContextServices(IServiceCollection services)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string connectionString;
|
|
|
|
string? connectionString;
|
|
|
|
|
|
|
|
|
|
|
|
switch (Environment.GetEnvironmentVariable("TYPE"))
|
|
|
|
switch (Environment.GetEnvironmentVariable("TYPE"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case "BDD":
|
|
|
|
case "BDD":
|
|
|
|
var HOST = System.Environment.GetEnvironmentVariable("HOST");
|
|
|
|
var host = Environment.GetEnvironmentVariable("HOST");
|
|
|
|
var PORT = System.Environment.GetEnvironmentVariable("PORTDB");
|
|
|
|
var port = Environment.GetEnvironmentVariable("PORTDB");
|
|
|
|
var DATABASE = System.Environment.GetEnvironmentVariable("DATABASE");
|
|
|
|
var database = Environment.GetEnvironmentVariable("DATABASE");
|
|
|
|
var USERNAME = System.Environment.GetEnvironmentVariable("USERNAME");
|
|
|
|
var username = Environment.GetEnvironmentVariable("USERNAME");
|
|
|
|
var PASSWORD = System.Environment.GetEnvironmentVariable("PASSWORD");
|
|
|
|
var password = Environment.GetEnvironmentVariable("PASSWORD");
|
|
|
|
|
|
|
|
|
|
|
|
connectionString = $"Server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}";
|
|
|
|
connectionString = $"Server={host};port={port};database={database};user={username};password={password}";
|
|
|
|
Console.WriteLine("========RUNNING USING THE MYSQL SERVER==============");
|
|
|
|
Console.WriteLine("========RUNNING USING THE MYSQL SERVER==============");
|
|
|
|
Console.WriteLine(connectionString);
|
|
|
|
Console.WriteLine(connectionString);
|
|
|
|
Console.WriteLine(connectionString);
|
|
|
|
Console.WriteLine(connectionString);
|
|
|
|
Console.WriteLine("======================");
|
|
|
|
Console.WriteLine("======================");
|
|
|
|
// with auth when it was working was'nt here
|
|
|
|
|
|
|
|
services.AddDbContext<AuthDbContext>(options => options.UseInMemoryDatabase("AuthDb"));
|
|
|
|
services.AddDbContext<AuthDbContext>(options => options.UseInMemoryDatabase("AuthDb"));
|
|
|
|
services.AddDbContext<HeartTrackContext>(options =>
|
|
|
|
services.AddDbContext<HeartTrackContext>(options =>
|
|
|
|
options.UseMySql($"{connectionString}", new MySqlServerVersion(new Version(10, 11, 1)))
|
|
|
|
options.UseMySql($"{connectionString}", new MySqlServerVersion(new Version(10, 11, 1)))
|
|
|
|
, ServiceLifetime.Singleton);
|
|
|
|
, ServiceLifetime.Singleton);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
Console.WriteLine("====== RUNNING USING THE IN SQLLITE DATABASE ======");
|
|
|
|
Console.WriteLine("====== RUNNING USING THE IN SQLITE DATABASE ======");
|
|
|
|
connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection");
|
|
|
|
connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection");
|
|
|
|
if (!string.IsNullOrWhiteSpace(connectionString))
|
|
|
|
if (!string.IsNullOrWhiteSpace(connectionString))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -109,7 +105,6 @@ public class AppBootstrap(IConfiguration configuration)
|
|
|
|
|
|
|
|
|
|
|
|
services.AddIdentityApiEndpoints<IdentityUser>()
|
|
|
|
services.AddIdentityApiEndpoints<IdentityUser>()
|
|
|
|
.AddEntityFrameworkStores<AuthDbContext>();
|
|
|
|
.AddEntityFrameworkStores<AuthDbContext>();
|
|
|
|
//services.AddIdentity<AthleteEntity, IdentityRole>()
|
|
|
|
|
|
|
|
// .AddEntityFrameworkStores<AuthDbContext>().AddDefaultTokenProviders();
|
|
|
|
// .AddEntityFrameworkStores<AuthDbContext>().AddDefaultTokenProviders();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -121,8 +116,6 @@ public class AppBootstrap(IConfiguration configuration)
|
|
|
|
opt.ReportApiVersions = true;
|
|
|
|
opt.ReportApiVersions = true;
|
|
|
|
opt.AssumeDefaultVersionWhenUnspecified = true;
|
|
|
|
opt.AssumeDefaultVersionWhenUnspecified = true;
|
|
|
|
opt.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0);
|
|
|
|
opt.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0);
|
|
|
|
// options.ApiVersionReader = new HeaderApiVersionReader("api-version");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
|
|
|
|
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
|
|
|
|
new HeaderApiVersionReader("x-api-version"),
|
|
|
|
new HeaderApiVersionReader("x-api-version"),
|
|
|
|
new MediaTypeApiVersionReader("x-api-version"));
|
|
|
|
new MediaTypeApiVersionReader("x-api-version"));
|
|
|
@ -171,12 +164,7 @@ public class AppBootstrap(IConfiguration configuration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
options.OperationFilter<SwaggerDefaultValues>();
|
|
|
|
options.OperationFilter<SwaggerDefaultValues>();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
/* services.AddSwaggerGen(options =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "HeartTrackAPI", Version = "v1" });
|
|
|
|
|
|
|
|
options.SwaggerDoc("v2", new OpenApiInfo { Title = "HeartTrackAPI", Version = "v2" });
|
|
|
|
|
|
|
|
});*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services.AddVersionedApiExplorer(setup =>
|
|
|
|
services.AddVersionedApiExplorer(setup =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setup.GroupNameFormat = "'v'VVV";
|
|
|
|
setup.GroupNameFormat = "'v'VVV";
|
|
|
@ -205,8 +193,6 @@ public class AppBootstrap(IConfiguration configuration)
|
|
|
|
app.UseSwaggerUI(options =>
|
|
|
|
app.UseSwaggerUI(options =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
|
|
|
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (var description in apiVersionDescriptionProvider)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
|
|
|
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
|
|
|
description.GroupName.ToUpperInvariant());
|
|
|
|
description.GroupName.ToUpperInvariant());
|
|
|
|