Skip to content

Commit

Permalink
A few minor fixes (#36)
Browse files Browse the repository at this point in the history
* Use cached layers for Dockerfile to improve build times locally.
* Set longer expiration on the cookie that remembers your prefered user
* Ignore a few nullability warnings to make the build warning free
** I don't have any idea about better error handeling than a NullPointerException
    so I just ignore with !
  • Loading branch information
ivarne authored May 26, 2023
1 parent 0d72a3f commit 340d0c4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build

COPY ./src ./src

WORKDIR /src

COPY ./src/LocalTest.csproj .
RUN dotnet restore LocalTest.csproj
RUN dotnet build LocalTest.csproj -c Release -o /app_output

COPY ./src .
RUN dotnet publish LocalTest.csproj -c Release -o /app_output

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS final
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ private void CreateJwtCookieAndAppendToResponse(string identityCookie, int altin
SecurePolicy = CookieSecurePolicy.None,
IsEssential = true,
Domain = _generalSettings.Hostname,
Expiration = new TimeSpan(0, 1337, 0)
MaxAge = TimeSpan.FromDays(365),
};
CookieOptions partyCookieOptions = partyCookieBuilder.Build(HttpContext);
cookieManager.AppendResponseCookie(
Expand All @@ -474,7 +474,7 @@ private void CreateJwtCookieAndAppendToResponse(string identityCookie, int altin
SecurePolicy = CookieSecurePolicy.None,
IsEssential = true,
Domain = _generalSettings.Hostname,
Expiration = TimeSpan.MaxValue,
MaxAge = TimeSpan.FromDays(365),
};
CookieOptions userSelectCookieOptions = cookieBuilder.Build(HttpContext);
cookieManager.AppendResponseCookie(
Expand Down
4 changes: 2 additions & 2 deletions src/Services/LocalApp/Implementation/LocalAppHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public LocalAppHttp(IOptions<GeneralSettings> generalSettings, IHttpClientFactor
return await _httpClient.GetStringAsync($"{appId}/api/v1/applicationmetadata?checkOrgApp=false");
});

return JsonSerializer.Deserialize<Application>(content, JSON_OPTIONS);
return JsonSerializer.Deserialize<Application>(content!, JSON_OPTIONS);
}

public async Task<TextResource?> GetTextResource(string org, string app, string language)
Expand All @@ -71,7 +71,7 @@ public LocalAppHttp(IOptions<GeneralSettings> generalSettings, IHttpClientFactor
return await _httpClient.GetStringAsync($"{org}/{app}/api/v1/texts/{language}");
});

var textResource = JsonSerializer.Deserialize<TextResource>(content, JSON_OPTIONS);
var textResource = JsonSerializer.Deserialize<TextResource>(content!, JSON_OPTIONS);
if (textResource != null)
{
textResource.Id = $"{org}-{app}-{language}";
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Register/Implementation/PartiesWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public async Task<int> LookupPartyIdBySSNOrOrgNo(string lookupValue)
}

/// <inheritdoc />
public async Task<List<Party>> GetPartyList(List<int> partyIds)
public async Task<List<Party?>> GetPartyList(List<int> partyIds)
{
var data = await _testDataService.GetTestData();
List<Party> filteredList = new List<Party>();
List<Party?> filteredList = new List<Party?>();
foreach (int partyId in partyIds.Distinct())
{
Party? party = data.Register.Party.TryGetValue(partyId.ToString()!, out var value) ? value : null;
Expand Down
4 changes: 2 additions & 2 deletions src/Services/TestData/TestDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public TestDataService(ILocalApp localApp, IOptions<LocalPlatformSettings> setti

public async Task<TestDataModel> GetTestData()
{
return await _cache.GetOrCreateAsync("TEST_DATA",
return (await _cache.GetOrCreateAsync("TEST_DATA",
async (entry) =>
{
entry.SlidingExpiration = TimeSpan.FromSeconds(5);
Expand All @@ -43,6 +43,6 @@ public async Task<TestDataModel> GetTestData()
}

return await TestDataDiskReader.ReadFromDisk(_settings.LocalTestingStaticTestDataPath);
});
}))!;
}
}

0 comments on commit 340d0c4

Please sign in to comment.