From df0756ff504c519b0b7391c0a9138205ca123279 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 15:29:23 +0100 Subject: [PATCH] change route --- .../Contact/DeleteContactEndpoint.cs | 2 +- .../Customer/CreateCustomerEndpoint.cs | 2 +- .../Customer/DeleteCustomerEndpoint.cs | 2 +- .../Customer/GetAllCustomerEndpoint.cs | 2 +- .../Endpoints/Customer/GetCustomerEndpoint.cs | 2 +- .../Customer/UpdateCustomerEndpoint.cs | 2 +- .../CreateCustomerTypeEndpoint.cs | 2 +- .../DeleteCustomerTypeEndpoint.cs | 2 +- .../GetAllCustomerTypeEndpoint.cs | 2 +- .../CustomerType/GetCustomerTypeEndpoint.cs | 2 +- .../CustomerType/UpdateCustomerEndpoint.cs | 2 +- .../CreateExperienceLevelEndpoint.cs | 2 +- .../DeleteExerienceLevelEndpoint.cs | 2 +- .../GetAllExperienceLevelsEndpoint.cs | 2 +- .../GetExperienceLevelEndpoint.cs | 2 +- .../UpdateExperienceLevelEndpoint.cs | 2 +- .../CreateHistoryOfApprovalEndpoint.cs | 2 +- .../DeleteHistoryOfApprovalEndpoint.cs | 2 +- .../GetAllHistoryOfApprovalEndpoint.cs | 2 +- .../GetHistoryOfApprovalEndpoint.cs | 2 +- .../UpdateHistoryOfApprovalEndpoint.cs | 2 +- .../Endpoints/Staff/CreateStaffEndpoint.cs | 2 +- .../Endpoints/Staff/DeleteStaffEndpoint.cs | 2 +- .../Endpoints/Staff/GetAllStaffsEndpoint.cs | 2 +- PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs | 2 +- .../Endpoints/Staff/UpdateStaffRequest.cs | 2 +- PyroFetes/Program.cs | 48 ++++++++++++++----- PyroFetes/PyroFetes.csproj | 2 + 28 files changed, 64 insertions(+), 38 deletions(-) diff --git a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs index 51a965c..530417d 100644 --- a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp { public override void Configure() { - Delete ("/api/Contacts/{@Id}", x => new { x.Id }); + Delete ("/api/contacts/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs index 0d92c29..3b51b5b 100644 --- a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Post("/api/Customer"); + Post("/api/customer"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs index aa434d8..a812115 100644 --- a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Delete ("/api/Customer/{@Id}", x => new { x.Id }); + Delete ("/api/customer/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs index 216f8d8..d96f3dc 100644 --- a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Get ("/api/Customer"); + Get ("/api/customer"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs index 0c9de44..be1d2e0 100644 --- a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Get ("/api/Customer/{@Id}", x => new { x.Id }); + Get ("/api/customer/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs index 9cdcaf8..4f4c22b 100644 --- a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomer(PyroFetesDbContext pyroFetesDbContext) : Endpoint new { x.Id }); + Put ("/api/customer/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs index 096f773..b0d00d7 100644 --- a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Post("/api/CustomerType"); + Post("/api/customertype"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs index 9e67e81..48d2982 100644 --- a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs @@ -11,7 +11,7 @@ public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Delete ("/api/CustomerType/{@Id}", x => new { x.Id }); + Delete ("/api/customertype/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs index 449aa9f..5dba9e7 100644 --- a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Get ("/api/CustomerType"); + Get ("/api/customertype"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs index c1f7599..e5047f4 100644 --- a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/CustomerType/{@Id}", x => new { x.Id }); + Get ("/api/customertype/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs index 0c8a362..981953f 100644 --- a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomerType(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Put ("/api/CustomerType/{@Id}", x => new { x.Id }); + Put ("/api/customertype/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs index ef4ccc6..a87fc05 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { public override void Configure() { - Post("/api/ExperienceLevels"); + Post("/api/experiencelevels"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs index 2fc0a96..8f0190f 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Delete ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); + Delete ("/api/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs index c04d6e7..f51e754 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContex { public override void Configure() { - Get ("/api/experienceLevels"); + Get ("/api/experiencelevels"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs index 9236f07..aca625a 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Get ("/api/experienceLevels/{@Id}", x => new { x.Id }); + Get ("/api/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs index e928e41..932b878 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { public override void Configure() { - Put ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); + Put ("/api/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs index d5251ae..f2a845d 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs @@ -8,7 +8,7 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Post("/api/HistoryOfApprovals"); + Post("/api/historyofapprovals"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs index 0095177..7cc5fa7 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Delete ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + Delete ("/api/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs index cc0cd48..843d200 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Get ("/api/HistoryOfApprovals"); + Get ("/api/historyofapprovals"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs index eb3f70c..d00bc12 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class GetHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Get ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + Get ("/api/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs index e5c98e6..3d37d7c 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Put ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + Put ("/api/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs index 06f6e64..bdaec96 100644 --- a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs @@ -8,7 +8,7 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Post("/api/availabilities"); + Post("/api/staffs"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs index 1af08ee..b57e85d 100644 --- a/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Delete ("/api/staff/{@Id}", x => new { x.Id }); + Delete ("/api/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs index 479b670..e06c013 100644 --- a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpo { public override void Configure() { - Get ("/api/availabilities"); + Get ("/api/staffs"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs index 73e95fe..2f208e3 100644 --- a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs @@ -9,7 +9,7 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { - Get ("/api/Staffs/{@Id}", x => new { x.Id }); + Get ("/api/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs index eb9ef7f..a17012e 100644 --- a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs +++ b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs @@ -9,7 +9,7 @@ public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Put ("/api/Staffs/{@Id}", x => new { x.Id }); + Put ("/api/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs index d127d73..03ac2b2 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -1,19 +1,43 @@ -var builder = WebApplication.CreateBuilder(args); +using PyroFetes; +using FastEndpoints; +using FastEndpoints.Swagger; +using FastEndpoints.Security; -// Add services to the container. -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); +WebApplicationBuilder builder = WebApplication.CreateBuilder(args); -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. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} +// On ajoute ici la configuration de la base de données +builder.Services.AddDbContext(); + +//On ajoute le CORS au code +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.UseCors(); + app.Run(); \ No newline at end of file diff --git a/PyroFetes/PyroFetes.csproj b/PyroFetes/PyroFetes.csproj index b301a92..ed5ce50 100644 --- a/PyroFetes/PyroFetes.csproj +++ b/PyroFetes/PyroFetes.csproj @@ -7,7 +7,9 @@ + +