forked from sanchezvem/PyroFetes
MAJ program pour liaison avec front
This commit is contained in:
@@ -1,29 +1,43 @@
|
||||
using API;
|
||||
using FastEndpoints;
|
||||
using FastEndpoints.Swagger;
|
||||
using PyroFetes;
|
||||
using FastEndpoints.Security;
|
||||
|
||||
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
||||
builder.Services
|
||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
||||
.AddAuthorization()
|
||||
.AddFastEndpoints()
|
||||
.SwaggerDocument();
|
||||
//builder.Services
|
||||
// .AddAuthenticationJwtBearer(s => s.SigningKey = "Thesecretusedtosigntokens")
|
||||
// .AddAuthentication();
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
options.AddDefaultPolicy(policyBuilder =>
|
||||
policyBuilder.WithOrigins("http://localhost:61021")
|
||||
.WithMethods("GET", "POST", "PUT", "PATCH", "DELETE")
|
||||
.AllowAnyHeader()
|
||||
)
|
||||
);
|
||||
//builder.Services.AddAuthorization();
|
||||
|
||||
|
||||
builder.Services.AddFastEndpoints().SwaggerDocument(
|
||||
options =>
|
||||
{
|
||||
options.ShortSchemaNames = true;
|
||||
});
|
||||
|
||||
// On ajoute ici la configuration de la base de données
|
||||
builder.Services.AddDbContext<PyroFetesDbContext>();
|
||||
|
||||
// On construit l'application en lui donnant vie
|
||||
WebApplication app = builder.Build();
|
||||
app.UseAuthentication()
|
||||
.UseAuthorization()
|
||||
.UseFastEndpoints()
|
||||
.UseSwaggerGen();
|
||||
// app.UseAuthorization()
|
||||
// .UseAuthentication();
|
||||
app.UseFastEndpoints(options =>
|
||||
{
|
||||
options.Endpoints.RoutePrefix = "API";
|
||||
options.Endpoints.ShortNames = true;
|
||||
}
|
||||
).UseSwaggerGen();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseCors();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user