change route

This commit is contained in:
2025-12-04 15:29:23 +01:00
parent 0a001e15e3
commit df0756ff50
28 changed files with 64 additions and 38 deletions

View File

@@ -9,7 +9,7 @@ public class DeleteContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
{ {
public override void Configure() public override void Configure()
{ {
Delete ("/api/Contacts/{@Id}", x => new { x.Id }); Delete ("/api/contacts/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End
{ {
public override void Configure() public override void Configure()
{ {
Post("/api/Customer"); Post("/api/customer");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class DeleteCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End
{ {
public override void Configure() public override void Configure()
{ {
Delete ("/api/Customer/{@Id}", x => new { x.Id }); Delete ("/api/customer/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/Customer"); Get ("/api/customer");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class GetCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/Customer/{@Id}", x => new { x.Id }); Get ("/api/customer/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class UpdateCustomer(PyroFetesDbContext pyroFetesDbContext) : Endpoint <U
{ {
public override void Configure() public override void Configure()
{ {
Put ("/api/Customer/{@Id}", x => new { x.Id }); Put ("/api/customer/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class CreateCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{ {
public override void Configure() public override void Configure()
{ {
Post("/api/CustomerType"); Post("/api/customertype");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -11,7 +11,7 @@ public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{ {
public override void Configure() public override void Configure()
{ {
Delete ("/api/CustomerType/{@Id}", x => new { x.Id }); Delete ("/api/customertype/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class GetAllCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/CustomerType"); Get ("/api/customertype");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class GetCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : En
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/CustomerType/{@Id}", x => new { x.Id }); Get ("/api/customertype/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class UpdateCustomerType(PyroFetesDbContext pyroFetesDbContext) : Endpoin
{ {
public override void Configure() public override void Configure()
{ {
Put ("/api/CustomerType/{@Id}", x => new { x.Id }); Put ("/api/customertype/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
{ {
public override void Configure() public override void Configure()
{ {
Post("/api/ExperienceLevels"); Post("/api/experiencelevels");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext)
{ {
public override void Configure() public override void Configure()
{ {
Delete ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); Delete ("/api/experiencelevels/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContex
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/experienceLevels"); Get ("/api/experiencelevels");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/experienceLevels/{@Id}", x => new { x.Id }); Get ("/api/experiencelevels/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
{ {
public override void Configure() public override void Configure()
{ {
Put ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); Put ("/api/experiencelevels/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{ {
public override void Configure() public override void Configure()
{ {
Post("/api/HistoryOfApprovals"); Post("/api/historyofapprovals");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{ {
public override void Configure() public override void Configure()
{ {
Delete ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); Delete ("/api/historyofapprovals/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/HistoryOfApprovals"); Get ("/api/historyofapprovals");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class GetHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext)
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); Get ("/api/historyofapprovals/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class UpdateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{ {
public override void Configure() public override void Configure()
{ {
Put ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); Put ("/api/historyofapprovals/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
{ {
public override void Configure() public override void Configure()
{ {
Post("/api/availabilities"); Post("/api/staffs");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
{ {
public override void Configure() public override void Configure()
{ {
Delete ("/api/staff/{@Id}", x => new { x.Id }); Delete ("/api/staffs/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -8,7 +8,7 @@ public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpo
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/availabilities"); Get ("/api/staffs");
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint
{ {
public override void Configure() public override void Configure()
{ {
Get ("/api/Staffs/{@Id}", x => new { x.Id }); Get ("/api/staffs/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -9,7 +9,7 @@ public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoin
{ {
public override void Configure() public override void Configure()
{ {
Put ("/api/Staffs/{@Id}", x => new { x.Id }); Put ("/api/staffs/{@Id}", x => new { x.Id });
AllowAnonymous(); AllowAnonymous();
} }

View File

@@ -1,19 +1,43 @@
var builder = WebApplication.CreateBuilder(args); using PyroFetes;
using FastEndpoints;
using FastEndpoints.Swagger;
using FastEndpoints.Security;
// Add services to the container. WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build(); // On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
builder.Services
.AddAuthenticationJwtBearer(s => s.SigningKey = "zewsxrdctfvgybuhbgyvftrcdtfvgbyuhn")
.AddAuthorization()
.AddFastEndpoints().SwaggerDocument(options => { options.ShortSchemaNames = true;});
// Configure the HTTP request pipeline. // On ajoute ici la configuration de la base de données
if (app.Environment.IsDevelopment()) builder.Services.AddDbContext<PyroFetesDbContext>();
{
app.UseSwagger(); //On ajoute le CORS au code
app.UseSwaggerUI(); builder.Services.AddCors(options =>
} { options.AddDefaultPolicy(policyBuilder =>
{
policyBuilder
.WithOrigins("http://localhost:4200")
.WithMethods("GET", "POST", "PUT", "PATCH", "DELETE")
.AllowAnyHeader();
});
});
// On construit l'application en lui donnant vie
WebApplication app = builder.Build();
app.UseAuthentication()
.UseAuthorization()
.UseFastEndpoints(options =>
{
options.Endpoints.RoutePrefix = "API";
options.Endpoints.ShortNames = true;
}
).UseSwaggerGen();
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseCors();
app.Run(); app.Run();

View File

@@ -7,7 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="FastEndpoints" Version="7.0.1" /> <PackageReference Include="FastEndpoints" Version="7.0.1" />
<PackageReference Include="FastEndpoints.Security" Version="7.0.1" />
<PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" /> <PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />