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()
{
Delete ("/api/Contacts/{@Id}", x => new { x.Id });
Delete ("/api/contacts/{@Id}", x => new { x.Id });
AllowAnonymous();
}

View File

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

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

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

View File

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

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

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

View File

@@ -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();
}

View File

@@ -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();
}

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.
// 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())
// On ajoute ici la configuration de la base de données
builder.Services.AddDbContext<PyroFetesDbContext>();
//On ajoute le CORS au code
builder.Services.AddCors(options =>
{ options.AddDefaultPolicy(policyBuilder =>
{
app.UseSwagger();
app.UseSwaggerUI();
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();

View File

@@ -7,7 +7,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<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="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />