Skip to content

Commit

Permalink
Merge pull request #571 from Crypter-File-Transfer/stable
Browse files Browse the repository at this point in the history
Merge 'stable' to 'main'
  • Loading branch information
Jack-Edwards authored Jul 8, 2023
2 parents 9f5eb79 + 3a6fb00 commit 0aac4f6
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
API_SETTINGS_FILE=./Containers/API/appsettings.json
API_STORAGE_PATH=./Containers/API/storage
API_SETTINGS_FILE=./Volumes/API/appsettings.json
API_STORAGE_PATH=./Volumes/API/storage
ASPNETCORE_ENVIRONMENT=Development
CADDY_DOMAIN=localhost
CADDY_REDIRECT_TO_WWW=127.0.0.1
CADDY_OPTIONS=""
CADDY_TLS_VOLUME=./Containers/Caddy/tls
CADDY_TLS_VOLUME=./Volumes/Caddy/tls
CADDY_MAX_REQUEST_BODY=130MB
POSTGRES_BIND_IP=""
POSTGRES_HOST=""
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Custom entries
/Containers/PostgreSQL/postgres-data/

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand Down
6 changes: 3 additions & 3 deletions Crypter.API/Crypter.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<ProjectReference Include="..\Crypter.Core\Crypter.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.8" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions Crypter.Core/Crypter.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.2" />
<PackageReference Include="Hangfire.Core" Version="1.8.2" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.19.12" />
<PackageReference Include="Hashids.net" Version="1.7.0" />
<PackageReference Include="MailKit" Version="4.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.5" />
<PackageReference Include="MimeKit" Version="4.0.0" />
<PackageReference Include="MailKit" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.8" />
<PackageReference Include="MimeKit" Version="4.1.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.30.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.31.0" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 1 addition & 19 deletions Crypter.Core/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,12 @@ public class DataContext : DbContext
{
public const string SchemaName = "crypter";

private readonly ILogger<DataContext> _logger;

/// <summary>
/// This constructor is used during migrations.
/// </summary>
/// <param name="options"></param>
public DataContext(DbContextOptions<DataContext> options, ILogger<DataContext> logger)
: base(options)
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
_logger = logger;
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.LogTo(
filter: (eventId, level) => eventId.Id == CoreEventId.ExecutionStrategyRetrying,
logger: (eventData) =>
{
ExecutionStrategyEventData retryEventData = eventData as ExecutionStrategyEventData;
IReadOnlyList<Exception> exceptions = retryEventData.ExceptionsEncountered;
_logger.LogWarning("Retry #{count} with delay {delay} due to error: {error}", exceptions.Count, retryEventData.Delay, exceptions[exceptions.Count - 1].Message);
});

base.OnConfiguring(optionsBuilder);
}

public DbSet<UserEntity> Users { get; set; }
Expand Down
18 changes: 16 additions & 2 deletions Crypter.Core/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

using System;
using System.Collections.Generic;
using Crypter.Core.Identity;
using Crypter.Core.Models;
using Crypter.Core.Repositories;
Expand All @@ -36,9 +37,11 @@
using Hangfire;
using Hangfire.PostgreSql;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;

namespace Crypter.Core
{
Expand All @@ -53,13 +56,24 @@ public static IServiceCollection AddCrypterCore(this IServiceCollection services
string defaultConnectionString,
string hangfireConnectionString)
{
services.AddDbContext<DataContext>(optionsBuilder =>
var serviceProvider = services.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<DataContext>>();

services.AddDbContextPool<DataContext>(optionsBuilder =>
{
optionsBuilder.UseNpgsql(defaultConnectionString, npgsqlOptionsBuilder =>
{
npgsqlOptionsBuilder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(5), new string[] { "57P01" });
npgsqlOptionsBuilder.MigrationsHistoryTable(HistoryRepository.DefaultTableName, DataContext.SchemaName);
});
})
.LogTo(
filter: (eventId, level) => eventId.Id == CoreEventId.ExecutionStrategyRetrying,
logger: (eventData) =>
{
ExecutionStrategyEventData retryEventData = eventData as ExecutionStrategyEventData;
IReadOnlyList<Exception> exceptions = retryEventData.ExceptionsEncountered;
logger.LogWarning("Retry #{count} with delay {delay} due to error: {error}", exceptions.Count, retryEventData.Delay, exceptions[exceptions.Count - 1].Message);
});
});

services.TryAddSingleton<IPasswordHashService, PasswordHashService>();
Expand Down
4 changes: 2 additions & 2 deletions Crypter.Test/Crypter.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.8" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Respawn" Version="6.0.0" />
<PackageReference Include="Testcontainers" Version="3.3.0" />
<PackageReference Include="TestContainers.Container.Database.PostgreSql" Version="1.5.4" />
Expand Down
4 changes: 2 additions & 2 deletions Crypter.Web/Crypter.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

<ItemGroup>
<PackageReference Include="ByteSize" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Crypter.Web/Shared/Modal/Template/ModalBehavior.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@inherits ModalBehaviorBase

<div class="modal @ModalClass" tabindex="-1" role="dialog" style="display:@ModalDisplay">
<div class="modal" tabindex="-1" role="dialog" style="display:@ModalDisplay">
<div class="modal-dialog" role="document">
@if (Show)
{
Expand Down
4 changes: 0 additions & 4 deletions Crypter.Web/Shared/Modal/Template/ModalBehavior.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,20 @@ public partial class ModalBehaviorBase : ComponentBase

private const string _modalDisplayNone = "none;";
private const string _modalDisplayBlock = "block;";
private const string _modalClassShow = "Show";

protected bool Show = false;
protected string ModalDisplay = _modalDisplayNone;
protected string ModalClass = string.Empty;

public void Open()
{
ModalDisplay = _modalDisplayBlock;
ModalClass = _modalClassShow;
Show = true;
StateHasChanged();
}

public void Close()
{
ModalDisplay = _modalDisplayNone;
ModalClass = string.Empty;
Show = false;
StateHasChanged();
}
Expand Down

0 comments on commit 0aac4f6

Please sign in to comment.