Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
v7.12.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-nitehawk committed Dec 5, 2023
1 parent db53595 commit 58b5020
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 55 deletions.
2 changes: 1 addition & 1 deletion MongoWebApiStarterTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>

<PackageVersion>7.12.0</PackageVersion>
<PackageVersion>7.12.1</PackageVersion>

<PackageType>Template</PackageType>
<PackageId>MongoWebApiStarter</PackageId>
Expand Down
22 changes: 11 additions & 11 deletions Template/Source/MongoWebApiStarter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SimpleEmailV2" Version="3.7.300.11" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="FastEndpoints" Version="5.20.0" />
<PackageReference Include="FastEndpoints.Security" Version="5.20.0" />
<PackageReference Include="FastEndpoints.Swagger" Version="5.20.0" />
<PackageReference Include="Flurl" Version="3.0.7" />
<PackageReference Include="Flurl.Http" Version="3.2.4" />
<PackageReference Include="MlkPwgen" Version="0.3.0" />
<PackageReference Include="MongoDB.Entities" Version="23.0.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="AWSSDK.SimpleEmailV2" Version="3.7.300.13"/>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3"/>
<PackageReference Include="FastEndpoints" Version="5.20.1"/>
<PackageReference Include="FastEndpoints.Security" Version="5.20.1"/>
<PackageReference Include="FastEndpoints.Swagger" Version="5.20.1"/>
<PackageReference Include="Flurl" Version="3.0.7"/>
<PackageReference Include="Flurl.Http" Version="3.2.4"/>
<PackageReference Include="MlkPwgen" Version="0.3.0"/>
<PackageReference Include="MongoDB.Entities" Version="23.0.0"/>
<PackageReference Include="NodaTime" Version="3.1.9"/>
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2"/>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Template/Source/Notifications/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial record Notification
public static async Task Initialize()
{
foreach (var t in await DB.Find<NotificationTemplate>().Match(_ => true).ExecuteAsync())
_templates.Add(t.ID!, t);
_templates.Add(t.ID, t);
}

public string ToName { get; init; } = null!;
Expand Down
7 changes: 2 additions & 5 deletions Template/Source/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
.Configure<Settings>(sec)
.AddHostedService<FileCleanerService>()
.AddSingleton<CloudFlareService>()
.AddSingleton(new AmazonSimpleEmailServiceV2Client(
awsAccessKeyId: stn.Email.ApiKey,
.AddSingleton(new AmazonSimpleEmailServiceV2Client(awsAccessKeyId: stn.Email.ApiKey,
awsSecretAccessKey: stn.Email.ApiSecret,
region: RegionEndpoint.USEast1))
.AddResponseCaching()
Expand Down Expand Up @@ -47,15 +46,13 @@
});

if (!bld.Environment.IsProduction())
{
app.UseSwaggerGen();
}

app.Run();

async Task InitDatabase()
{
BsonSerializer.RegisterSerializer(new ObjectSerializer(type => ObjectSerializer.DefaultAllowedTypes(type) || type.Name!.EndsWith("Message")));
BsonSerializer.RegisterSerializer(new ObjectSerializer(type => ObjectSerializer.DefaultAllowedTypes(type) || type.Name.EndsWith("Message")));
await DB.InitAsync(stn.Database.Name, stn.Database.Host);
await DB.InitAsync(stn.JobDatabase.Name, stn.JobDatabase.Host);
await DB.InitAsync(stn.FileBucket.Name, stn.FileBucket.Host);
Expand Down
2 changes: 1 addition & 1 deletion Template/Source/[Features]/Account/Get/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sealed class Mapper : Mapper<Request, Response, Dom.Account>
public override Response FromEntity(Dom.Account a)
=> new()
{
AccountID = a.ID!,
AccountID = a.ID,
City = a.Address.City,
CountryCode = a.Address.CountryCode,
EmailAddress = a.Email,
Expand Down
7 changes: 3 additions & 4 deletions Template/Source/[Features]/Account/Login/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ public override async Task HandleAsync(Request r, CancellationToken ct)
var expiryDate = DateTime.UtcNow.AddDays(1);
var permissions = new Allow();

Response.FullName = $"{acc!.Title} {acc.FirstName} {acc.LastName}";
Response.FullName = $"{acc.Title} {acc.FirstName} {acc.LastName}";
Response.Token.Expiry = expiryDate.ToLocal().ToString("yyyy-MM-ddTHH:mm:ss");
Response.PermissionSet = permissions.AllNames();
Response.Token.Value = JWTBearer.CreateToken(
signingKey: Settings.Value.Auth.SigningKey,
Response.Token.Value = JWTBearer.CreateToken(signingKey: Settings.Value.Auth.SigningKey,
expireAt: expiryDate,
privileges: u =>
{
u.Permissions.AddRange(permissions.AllCodes());
u[Claim.AccountID] = acc.ID!;
u[Claim.AccountID] = acc.ID;
});
}
}
4 changes: 2 additions & 2 deletions Template/Source/[Features]/Account/Save/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public override async Task HandleAsync(Request r, CancellationToken ct)
await SendVerificationEmailAsync(acc);

Response.EmailSent = _needsEmailVerification;
Response.ID = acc.ID!;
Response.ID = acc.ID;
}

async Task SendVerificationEmailAsync(Dom.Account a)
{
if (_needsEmailVerification && !_isTestEnv)
{
var code = PasswordGenerator.Generate(20);
await Data.SetEmailValidationCodeAsync(code, a.ID!);
await Data.SetEmailValidationCodeAsync(code, a.ID);

await new Notification
{
Expand Down
2 changes: 1 addition & 1 deletion Template/Source/[Features]/Image/Save/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public static async Task<string> UploadAsync(Dom.Image image, Stream stream)
await image.SaveAsync();
await image.Data.UploadWithTimeoutAsync(stream, 60, 128);

return image.ID!;
return image.ID;
}
}
32 changes: 15 additions & 17 deletions Template/Tests/Account/AccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public async Task Account_Creation()

var (rsp, res) = await Fixture.Client.POSTAsync<Save.Endpoint, Save.Request, Save.Response>(req);

rsp!.IsSuccessStatusCode.Should().BeTrue();
res!.EmailSent.Should().BeTrue();
rsp.IsSuccessStatusCode.Should().BeTrue();
res.EmailSent.Should().BeTrue();
res.ID.Should().NotBeNullOrEmpty();

Fixture.AccountID = res.ID;
Expand All @@ -33,12 +33,11 @@ public async Task Account_Verification()

var code = (await DB.Find<Dom.Account>().OneAsync(accountID))!.EmailVerificationCode;

await Fixture.Client.POSTAsync<Verify.Endpoint, Verify.Request>(
new()
{
ID = accountID!,
Code = code
});
await Fixture.Client.POSTAsync<Verify.Endpoint, Verify.Request>(new()
{
ID = accountID,
Code = code
});

var verified = await DB.Find<Dom.Account, bool>()
.Match(a => a.ID == accountID)
Expand All @@ -51,17 +50,16 @@ public async Task Account_Verification()
[Fact, Priority(3)]
public async Task Account_Login()
{
var (rsp, res) = await Fixture.Client.POSTAsync<Login.Endpoint, Login.Request, Login.Response>(
new()
{
UserName = Fixture.SaveRequest.EmailAddress,
Password = Fixture.SaveRequest.Password
});
var (rsp, res) = await Fixture.Client.POSTAsync<Login.Endpoint, Login.Request, Login.Response>(new()
{
UserName = Fixture.SaveRequest.EmailAddress,
Password = Fixture.SaveRequest.Password
});

var acc = await DB.Find<Dom.Account>().OneAsync(Fixture.AccountID);

rsp!.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);
res!.FullName.Should().Be($"{acc!.Title} {acc.FirstName} {acc.LastName}");
rsp.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);
res.FullName.Should().Be($"{acc!.Title} {acc.FirstName} {acc.LastName}");
res.PermissionSet.Should().HaveCount(7);
res.Token.Value.Should().NotBeNull();

Expand All @@ -75,7 +73,7 @@ public async Task Account_Retrieve()

var (_, res) = await Fixture.Client.GETAsync<Get.Endpoint, Get.Response>();

var acc = await DB.Find<Dom.Account>().OneAsync(res!.AccountID);
var acc = await DB.Find<Dom.Account>().OneAsync(res.AccountID);

var match =
acc!.Email == res.EmailAddress &&
Expand Down
22 changes: 13 additions & 9 deletions Template/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<RootNamespace>Tests</RootNamespace>
<RootNamespace>Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="FastEndpoints.Testing" Version="5.20.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="FastEndpoints.Testing" Version="5.20.1"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="xunit" Version="2.6.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Source\MongoWebApiStarter.csproj"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Source\MongoWebApiStarter.csproj" />
<Content Include="xunit.runner.json" CopyToOutputDirectory="Always"/>
</ItemGroup>

</Project>
</Project>
5 changes: 5 additions & 0 deletions Template/Tests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parallelizeAssembly": true,
"parallelizeTestCollections": true,
"diagnosticMessages": false
}
6 changes: 3 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- migrate project to .net 8
- upgrade dependencies
- misc. code refactors
- add `xunit.runner.json` file
- update `.editorconfig` file
- upgrade dependencies

0 comments on commit 58b5020

Please sign in to comment.