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

Commit

Permalink
upgrade fastendpoints to v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-nitehawk committed Jan 23, 2022
1 parent 44fe8e8 commit a98034c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 30 deletions.
6 changes: 2 additions & 4 deletions MongoWebApiStarterTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

<PropertyGroup>

<PackageVersion>7.6.0</PackageVersion>
<PackageVersion>7.6.1</PackageVersion>

<PackageReleaseNotes>
- implement separate domain entity mappers
- update vs extension
- upgrade dependancies
- upgrade fastendpoints to v3.0
</PackageReleaseNotes>

<PackageType>Template</PackageType>
Expand Down
12 changes: 6 additions & 6 deletions Template/Source/MongoWebApiStarter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.2" />
<PackageReference Include="FastEndpoints" Version="2.16.0" />
<PackageReference Include="FastEndpoints.Security" Version="2.16.0" />
<PackageReference Include="FastEndpoints.Swagger" Version="2.16.0" />
<PackageReference Include="Flurl" Version="3.0.2" />
<PackageReference Include="Flurl.Http" Version="3.2.0" />
<PackageReference Include="MailKit" Version="3.0.0" />
<PackageReference Include="FastEndpoints" Version="3.0.0" />
<PackageReference Include="FastEndpoints.Security" Version="3.0.0" />
<PackageReference Include="FastEndpoints.Swagger" Version="3.0.0" />
<PackageReference Include="Flurl" Version="3.0.3" />
<PackageReference Include="Flurl.Http" Version="3.2.1" />
<PackageReference Include="MailKit" Version="3.1.0" />
<PackageReference Include="MlkPwgen" Version="0.3.0" />
<PackageReference Include="NodaTime" Version="3.0.9" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
Expand Down
26 changes: 8 additions & 18 deletions Template/Source/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
global using FastEndpoints.Validation;
global using MongoDB.Entities;
using FastEndpoints.Swagger;
using Microsoft.AspNetCore.Http.Json;
using Microsoft.Extensions.Options;
using MongoWebApiStarter;
using MongoWebApiStarter.Services;
using Swashbuckle.AspNetCore.SwaggerUI;

var builder = WebApplication.CreateBuilder();
var configSection = builder.Configuration.GetSection(nameof(Settings));
builder.Services.Configure<Settings>(configSection);
builder.Services.Configure<JsonOptions>(o => o.SerializerOptions.PropertyNamingPolicy = null);

builder.Services.AddHostedService<EmailService>();
builder.Services.AddHostedService<FileCleanerService>();
Expand All @@ -22,32 +19,25 @@
builder.Services.AddResponseCaching();
builder.Services.AddFastEndpoints();
builder.Services.AddAuthenticationJWTBearer(configSection.Get<Settings>().Auth.SigningKey);
builder.Services.AddSwagger();
builder.Services.AddSwaggerDoc();

var app = builder.Build();

if (!app.Environment.IsProduction())
{
app.UseCors(b => b
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());

app.UseOpenApi();
app.UseSwaggerUi3(c => c.ConfigureDefaults());
}

app.UseAuthentication();
app.UseAuthorization();
app.UseResponseCaching();
app.UseFastEndpoints();

if (!app.Environment.IsProduction())
{
app.UseSwagger();
app.UseSwaggerUI(o =>
{
o.DocExpansion(DocExpansion.None);
o.DefaultModelExpandDepth(0);
});
}
app.UseFastEndpoints(c => c.SerializerOptions = o => o.PropertyNamingPolicy = null);

var settings = app.Services.GetRequiredService<IOptions<Settings>>().Value;
await DB.InitAsync(settings.Database.Name, settings.Database.Host);
Expand Down
2 changes: 1 addition & 1 deletion Template/Source/[Features]/Account/Login/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override async Task HandleAsync(Request r, CancellationToken ct)

var expiryDate = DateTime.UtcNow.AddDays(1);

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.Token.Value = JWTBearer.CreateToken(
signingKey: Settings.Value.Auth.SigningKey,
Expand Down
2 changes: 1 addition & 1 deletion Template/Tests/MongoWebApiStarter.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="FluentAssertions" Version="6.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
Expand Down

0 comments on commit a98034c

Please sign in to comment.