aboutsummaryrefslogtreecommitdiff
path: root/src/Web/DevHive.Web
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-02-15 19:06:14 +0200
committertranstrike <transtrike@gmail.com>2021-02-15 19:06:14 +0200
commit4c03712af14c37718b7be5b23fcadeb86f2a2191 (patch)
tree0c6b5a592244e5b2574afa9e4919d4a3111eea34 /src/Web/DevHive.Web
parent09fc4603e82f69c926f9457085aa3fa48bb3939c (diff)
downloadDevHive-4c03712af14c37718b7be5b23fcadeb86f2a2191.tar
DevHive-4c03712af14c37718b7be5b23fcadeb86f2a2191.tar.gz
DevHive-4c03712af14c37718b7be5b23fcadeb86f2a2191.zip
Code Analyzer added to all csproj; Removed unnessessary code; Fixed formatting
Diffstat (limited to 'src/Web/DevHive.Web')
-rw-r--r--src/Web/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs5
-rw-r--r--src/Web/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs2
-rw-r--r--src/Web/DevHive.Web/Configurations/Extensions/ConfigureJwt.cs (renamed from src/Web/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs)6
-rw-r--r--src/Web/DevHive.Web/DevHive.Web.csproj21
-rw-r--r--src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs14
5 files changed, 19 insertions, 29 deletions
diff --git a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs
index 8b7d657..0b8194e 100644
--- a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs
+++ b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs
@@ -1,6 +1,5 @@
using System;
using AutoMapper;
-//using AutoMapper.Configuration;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
@@ -15,10 +14,10 @@ namespace DevHive.Web.Configurations.Extensions
public static void UseAutoMapperConfiguration(this IApplicationBuilder app)
{
- var config = new MapperConfiguration(cfg =>
+ _ = new MapperConfiguration(cfg =>
{
cfg.AllowNullCollections = true;
});
}
}
-} \ No newline at end of file
+}
diff --git a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs
index 286727f..c017a8c 100644
--- a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs
+++ b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs
@@ -6,8 +6,6 @@ namespace DevHive.Web.Configurations.Extensions
{
public static class ConfigureExceptionHandlerMiddleware
{
- public static void ExceptionHandlerMiddlewareConfiguration(this IServiceCollection services) { }
-
public static void UseExceptionHandlerMiddlewareConfiguration(this IApplicationBuilder app)
{
app.UseMiddleware<ExceptionMiddleware>();
diff --git a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureJwt.cs
index d422bc8..03d4b11 100644
--- a/src/Web/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs
+++ b/src/Web/DevHive.Web/Configurations/Extensions/ConfigureJwt.cs
@@ -8,11 +8,11 @@ using Microsoft.IdentityModel.Tokens;
namespace DevHive.Web.Configurations.Extensions
{
- public static class JWTExtensions
+ public static class ConfigureJwt
{
public static void JWTConfiguration(this IServiceCollection services, IConfiguration configuration)
{
- services.AddSingleton(new JWTOptions(configuration
+ services.AddSingleton(new JwtOptions(configuration
.GetSection("AppSettings")
.GetSection("Secret")
.Value));
@@ -51,4 +51,4 @@ namespace DevHive.Web.Configurations.Extensions
});
}
}
-} \ No newline at end of file
+}
diff --git a/src/Web/DevHive.Web/DevHive.Web.csproj b/src/Web/DevHive.Web/DevHive.Web.csproj
index 6f78b69..6511c37 100644
--- a/src/Web/DevHive.Web/DevHive.Web.csproj
+++ b/src/Web/DevHive.Web/DevHive.Web.csproj
@@ -7,21 +7,22 @@
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.3" NoWarn="NU1605" />
- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.3" NoWarn="NU1605" />
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.3" NoWarn="NU1605"/>
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.3" NoWarn="NU1605"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
- <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
- <PackageReference Include="Swashbuckle.AspNetCore" Version="6.0.5" />
- <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
- <PackageReference Include="AutoMapper" Version="10.1.1" />
- <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.3" />
+ <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2"/>
+ <PackageReference Include="Swashbuckle.AspNetCore" Version="6.0.5"/>
+ <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1"/>
+ <PackageReference Include="AutoMapper" Version="10.1.1"/>
+ <PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.3"/>
+ <PackageReference Include="SonarAnalyzer.CSharp" Version="8.18.0.27296"/>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\DevHive.Web.Models\DevHive.Web.Models.csproj" />
- <ProjectReference Include="..\..\Services\DevHive.Services\DevHive.Services.csproj" />
+ <ProjectReference Include="..\DevHive.Web.Models\DevHive.Web.Models.csproj"/>
+ <ProjectReference Include="..\..\Services\DevHive.Services\DevHive.Services.csproj"/>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs b/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs
index cb6d4ca..f159b69 100644
--- a/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs
+++ b/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs
@@ -9,18 +9,11 @@ namespace DevHive.Web.Middleware
public class ExceptionMiddleware
{
private readonly RequestDelegate _next;
- // private readonly ILogger _logger;
public ExceptionMiddleware(RequestDelegate next)
{
this._next = next;
- // this._logger = logger;
}
- // public ExceptionMiddleware(RequestDelegate next, ILogger logger)
- // {
- // this._logger = logger;
- // this._next = next;
- // }
public async Task InvokeAsync(HttpContext httpContext)
{
@@ -30,20 +23,19 @@ namespace DevHive.Web.Middleware
}
catch (Exception ex)
{
- // this._logger.LogError($"Something went wrong: {ex}");
await HandleExceptionAsync(httpContext, ex);
}
}
- private Task HandleExceptionAsync(HttpContext context, Exception exception)
+ private static Task HandleExceptionAsync(HttpContext context, Exception exception)
{
context.Response.ContentType = "application/json";
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
return context.Response.WriteAsync(new
{
- StatusCode = context.Response.StatusCode,
- Message = exception.Message
+ context.Response.StatusCode,
+ exception.Message
}.ToString());
}
}