features/api-cleanup #15
@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newsbot.Collector.Api.Authentication;
|
using Newsbot.Collector.Api.Authentication;
|
||||||
|
using Newsbot.Collector.Api.Middleware;
|
||||||
using Newsbot.Collector.Domain.Entities;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
namespace Newsbot.Collector.Api.Authentication;
|
namespace Newsbot.Collector.Api.Middleware;
|
||||||
|
|
||||||
public static class JwtUserIdExtension
|
public static class JwtUserIdExtension
|
||||||
{
|
{
|
||||||
public static string GetUserId(this HttpContext context)
|
public static string GetUserId(this HttpContext context)
|
||||||
{
|
{
|
||||||
if (context.User == null)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.User.Claims.Single(x => x.Type == "id").Value;
|
return context.User.Claims.Single(x => x.Type == "id").Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -35,7 +35,7 @@ GlobalConfiguration.Configuration.UseSerilogLogProvider();
|
|||||||
|
|
||||||
// Build Health Checks
|
// Build Health Checks
|
||||||
builder.Services.AddHealthChecks()
|
builder.Services.AddHealthChecks()
|
||||||
.AddNpgSql(config.GetValue<string>(ConfigConnectionStringConst.Database) ?? "");
|
.AddNpgSql(config.GetValue<string>(ConfigConst.ConnectionStringDatabase) ?? "");
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
@ -109,7 +109,7 @@ static IConfiguration GetConfiguration()
|
|||||||
|
|
||||||
static ILogger GetLogger(IConfiguration configuration)
|
static ILogger GetLogger(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var otel = configuration.GetValue<string>(ConfigConnectionStringConst.OpenTelemetry) ?? "";
|
var otel = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry) ?? "";
|
||||||
|
|
||||||
if (otel == "")
|
if (otel == "")
|
||||||
return Log.Logger = new LoggerConfiguration()
|
return Log.Logger = new LoggerConfiguration()
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newsbot.Collector.Api.Domain;
|
using Newsbot.Collector.Api.Domain;
|
||||||
using Newsbot.Collector.Api.Services;
|
|
||||||
using Newsbot.Collector.Database;
|
using Newsbot.Collector.Database;
|
||||||
using Newsbot.Collector.Database.Repositories;
|
using Newsbot.Collector.Database.Repositories;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
using Newsbot.Collector.Services;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Startup;
|
namespace Newsbot.Collector.Api.Startup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user