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;
|
||||||
using FastEndpoints.Swagger;
|
using FastEndpoints.Swagger;
|
||||||
using PyroFetes;
|
using PyroFetes;
|
||||||
using FastEndpoints.Security;
|
|
||||||
|
|
||||||
|
|
||||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
//builder.Services
|
||||||
builder.Services
|
// .AddAuthenticationJwtBearer(s => s.SigningKey = "Thesecretusedtosigntokens")
|
||||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
// .AddAuthentication();
|
||||||
.AddAuthorization()
|
|
||||||
.AddFastEndpoints()
|
builder.Services.AddCors(options =>
|
||||||
.SwaggerDocument();
|
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>();
|
builder.Services.AddDbContext<PyroFetesDbContext>();
|
||||||
|
|
||||||
// On construit l'application en lui donnant vie
|
|
||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
app.UseAuthentication()
|
// app.UseAuthorization()
|
||||||
.UseAuthorization()
|
// .UseAuthentication();
|
||||||
.UseFastEndpoints()
|
app.UseFastEndpoints(options =>
|
||||||
.UseSwaggerGen();
|
{
|
||||||
|
options.Endpoints.RoutePrefix = "API";
|
||||||
|
options.Endpoints.ShortNames = true;
|
||||||
|
}
|
||||||
|
).UseSwaggerGen();
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseCors();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
Reference in New Issue
Block a user