Skip to content

Commit 2e51251

Browse files
authored
Merge pull request #31 from thejaviertc/dev
v.1.2.0
2 parents 5b396d4 + 00e674c commit 2e51251

29 files changed

+245
-244
lines changed

.github/workflows/cd.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,21 @@ jobs:
1616
- name: 📘 Setup .NET
1717
uses: actions/setup-dotnet@v4
1818
with:
19-
dotnet-version: 8.x.x
19+
dotnet-version: 9.x.x
2020

2121
- name: 🔄 Restore dependencies
2222
run: dotnet restore
2323

2424
- name: 🔨 Build Project
2525
run: dotnet build --no-restore
2626

27-
- name: 🧪 Test Project
28-
run: dotnet test --no-build --verbosity normal
29-
3027
- name: 🔎 SonarCloud Scan
31-
uses: highbyte/sonarscan-dotnet@v2.3.2
28+
uses: highbyte/sonarscan-dotnet@v2.4.2
3229
with:
3330
sonarProjectKey: thejaviertc_sws-api
3431
sonarProjectName: thejaviertc_sws-api
3532
sonarOrganization: thejaviertc
36-
sonarBeginArguments: /d:sonar.qualitygate.wait=true
33+
sonarBeginArguments: /d:sonar.qualitygate.wait=false
3734
dotnetDisableTests: true
3835
env:
3936
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,10 @@ jobs:
1616
- name: 📘 Setup .NET
1717
uses: actions/setup-dotnet@v4
1818
with:
19-
dotnet-version: 8.x.x
19+
dotnet-version: 9.x.x
2020

2121
- name: 🔄 Restore dependencies
2222
run: dotnet restore
2323

2424
- name: 🔨 Build Project
2525
run: dotnet build --no-restore
26-
27-
- name: 🧪 Test Project
28-
run: dotnet test --no-build --verbosity normal
29-
30-
- name: 🔎 SonarCloud Scan
31-
uses: highbyte/sonarscan-dotnet@v2.3.2
32-
with:
33-
sonarProjectKey: thejaviertc_sws-api
34-
sonarProjectName: thejaviertc_sws-api
35-
sonarOrganization: thejaviertc
36-
sonarBeginArguments: /d:sonar.qualitygate.wait=true
37-
dotnetDisableTests: true
38-
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
22
WORKDIR /app
33
EXPOSE 80
44
EXPOSE 443
55

66
USER app
7-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
7+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build
88
ARG configuration=Release
99
WORKDIR /src
10-
COPY src/SteamWorkshopStats.csproj src/
11-
RUN dotnet restore "src/SteamWorkshopStats.csproj"
10+
COPY SteamWorkshopStats/SteamWorkshopStats.csproj SteamWorkshopStats/
11+
RUN dotnet restore "SteamWorkshopStats/SteamWorkshopStats.csproj"
1212
COPY . .
1313
WORKDIR "/src"
14-
RUN dotnet build "src/SteamWorkshopStats.csproj" -c "$configuration" -o /app/build
14+
RUN dotnet build "SteamWorkshopStats/SteamWorkshopStats.csproj" -c "$configuration" -o /app/build
1515

1616
FROM build AS publish
1717
ARG configuration=Release
18-
RUN dotnet publish "src/SteamWorkshopStats.csproj" -c "$configuration" -o /app/publish /p:UseAppHost=false
18+
RUN dotnet publish "SteamWorkshopStats/SteamWorkshopStats.csproj" -c "$configuration" -o /app/publish /p:UseAppHost=false
1919

2020
FROM base AS final
2121
WORKDIR /app

SteamWorkshopStats.sln

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.8.34330.188
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWorkshopStats", "src\SteamWorkshopStats.csproj", "{37662DF4-08F8-4519-91CA-D7C8C8116A86}"
7-
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWorkshopStats.Tests", "tests\SteamWorkshopStats.Tests.csproj", "{3328B8FE-4D2A-4F5A-BF28-EE1FFE7DC893}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWorkshopStats", "SteamWorkshopStats\SteamWorkshopStats.csproj", "{37662DF4-08F8-4519-91CA-D7C8C8116A86}"
97
EndProject
108
Global
119
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,10 +15,6 @@ Global
1715
{37662DF4-08F8-4519-91CA-D7C8C8116A86}.Debug|Any CPU.Build.0 = Debug|Any CPU
1816
{37662DF4-08F8-4519-91CA-D7C8C8116A86}.Release|Any CPU.ActiveCfg = Release|Any CPU
1917
{37662DF4-08F8-4519-91CA-D7C8C8116A86}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{3328B8FE-4D2A-4F5A-BF28-EE1FFE7DC893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{3328B8FE-4D2A-4F5A-BF28-EE1FFE7DC893}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{3328B8FE-4D2A-4F5A-BF28-EE1FFE7DC893}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{3328B8FE-4D2A-4F5A-BF28-EE1FFE7DC893}.Release|Any CPU.Build.0 = Release|Any CPU
2418
EndGlobalSection
2519
GlobalSection(SolutionProperties) = preSolution
2620
HideSolutionNode = FALSE

src/Controllers/UserController.cs renamed to SteamWorkshopStats/Controllers/UserController.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Microsoft.AspNetCore.RateLimiting;
33
using SteamWorkshopStats.Models;
4+
using SteamWorkshopStats.Models.Records;
45
using SteamWorkshopStats.Services;
56

67
namespace SteamWorkshopStats.Controllers;
@@ -58,14 +59,14 @@ public async Task<ActionResult<User>> GetUserBySteamId(string steamId)
5859
/// <returns>An User</returns>
5960
private async Task<ActionResult<User>> GetUserAsync(string steamId)
6061
{
61-
var profileInfo = await _steamService.GetProfileInfoAsync(steamId);
62+
GetPlayerSummariesPlayer? profileInfo = await _steamService.GetProfileInfoAsync(steamId);
6263

6364
if (profileInfo is null)
6465
return NotFound(new { Message = "This User doesn't exists (Profile info not found)" });
6566

66-
var addons = await _steamService.GetAddonsAsync(steamId);
67+
List<Addon> addons = await _steamService.GetAddonsAsync(steamId);
6768

68-
var user = new User
69+
User user = new User
6970
{
7071
SteamId = steamId,
7172
Username = profileInfo.Username,
@@ -75,13 +76,11 @@ private async Task<ActionResult<User>> GetUserAsync(string steamId)
7576
Favorites = addons.Sum(addon => addon.Favorites),
7677
Likes = addons.Sum(addon => addon.Likes),
7778
Dislikes = addons.Sum(addon => addon.Dislikes),
78-
Addons = addons
79+
Addons = addons,
7980
};
8081

8182
if (_env.IsProduction())
82-
{
8383
_ = _discordService.LogUserAsync(user);
84-
}
8584

8685
return user;
8786
}
File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using NLog;
2+
using SteamWorkshopStats.Exceptions;
3+
using SteamWorkshopStats.Services;
4+
using SteamWorkshopStats.Utils;
5+
6+
namespace SteamWorkshopStats.Middlewares;
7+
8+
public class ErrorLoggerMiddleware
9+
{
10+
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
11+
12+
private readonly RequestDelegate _next;
13+
14+
private readonly IDiscordService _discordService;
15+
16+
public ErrorLoggerMiddleware(RequestDelegate next, IDiscordService discordService)
17+
{
18+
_next = next;
19+
_discordService = discordService;
20+
}
21+
22+
public async Task InvokeAsync(HttpContext context)
23+
{
24+
try
25+
{
26+
await _next(context);
27+
}
28+
catch (Exception ex)
29+
{
30+
_logger.Error(ex, "Unhandled exception:");
31+
_ = _discordService.LogErrorAsync(context.Request.Path, IpUtils.GetIp(context), ex.ToString());
32+
33+
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
34+
35+
await context.Response.WriteAsJsonAsync(
36+
new { Message = ex is SteamServiceException ? ex.Message : "HTTP 500 Internal Server Error" }
37+
);
38+
}
39+
}
40+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)