-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (39 loc) · 1.34 KB
/
Copy pathProgram.cs
File metadata and controls
44 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using Microsoft.EntityFrameworkCore;
using Panner.AspNetCore;
using Panner.AspNetCore.Samples.FastEndpointsNet9;
using Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel;
using Panner.AspNetCore.Samples.FastEndpointsNet9.PannerExtensions;
using Views = Panner.AspNetCore.Samples.FastEndpointsNet9.Views;
using Panner.Builders;
var bld = WebApplication.CreateBuilder(args);
bld.Services
.AddAuthenticationJwtBearer(s => s.SigningKey = bld.Configuration["Auth:JwtKey"])
.AddAuthorization()
.AddFastEndpoints(o => o.SourceGeneratorDiscoveredTypes = DiscoveredTypes.All)
.SwaggerDocument();
bld.Services.UsePanner(c =>
{
c.Entity<Post>()
.IsSortableByPopularity()
.Property(x => x.Id, o => o
.IsSortableAs(nameof(Views.Post.Id))
.IsFilterableAs(nameof(Views.Post.Id))
)
.Property(x => x.Title, o => o
.IsSortableAs(nameof(Views.Post.Title))
)
.Property(x => x.CreatedOn, o => o
.IsSortableAs(nameof(Views.Post.Creation))
.IsFilterableAs(nameof(Views.Post.Creation))
);
});
bld.Services.AddDbContext<BlogContext>(o => o.UseInMemoryDatabase("BlogDb"));
var app = bld.Build();
app.UseAuthentication()
.UseAuthorization()
.UseFastEndpoints(c =>
{
c.Errors.UseProblemDetails();
})
.UseSwaggerGen();
app.Run();