change name of all api routes
This commit is contained in:
@@ -8,7 +8,7 @@ public class CreateAuthorEndpoint(LibraryDbContext database) : Endpoint<CreateAu
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/authors");
|
Post("/authors");
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class DeleteAuthorEndpoint(LibraryDbContext database) : Endpoint<DeleteAu
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/authors/{@Id}", x => new {x.Id});
|
Delete("/authors/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetAllAuthorsEndpoint(LibraryDbContext database) : EndpointWithoutR
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/authors");
|
Get("/authors");
|
||||||
Roles("viewer", "admin", "librarian");
|
Roles("viewer", "admin", "librarian");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class GetAuthorEndpoint(LibraryDbContext database) : Endpoint<GetAuthorRe
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/authors/{@Id}", x => new {x.Id});
|
Get("/authors/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian");
|
Roles("viewer", "admin", "librarian");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class UpdateAuthorEndpoint(LibraryDbContext database) : Endpoint<UpdateAu
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/authors/{@Id}", x => new {x.Id});
|
Put("/authors/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class CreateBookEndpoint(LibraryDbContext database) : Endpoint<CreateBook
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/books");
|
Post("/books");
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class DeleteBookEndpoint(LibraryDbContext database) : Endpoint<DeleteBook
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/books/{@Id}", x => new {x.Id});
|
Delete("/books/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GetAllBooksEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/books");
|
Get("/books");
|
||||||
Roles("viewer", "admin", "librarian"); }
|
Roles("viewer", "admin", "librarian"); }
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class GetBookEndpoint(LibraryDbContext database) : Endpoint<GetBookReques
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/books/{@Id}", x => new {x.Id});
|
Get("/books/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian"); }
|
Roles("viewer", "admin", "librarian"); }
|
||||||
|
|
||||||
public override async Task HandleAsync(GetBookRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetBookRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateBookEndpoint(LibraryDbContext database) : Endpoint<UpdateBook
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/books/{@Id}", x => new {x.Id});
|
Put("/books/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class CreateLoanEndpoint(LibraryDbContext database) : Endpoint<CreateLoan
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/loans");
|
Post("/loans");
|
||||||
Roles("admin", "librarian");
|
Roles("admin", "librarian");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class DeleteLoanEndpoint(LibraryDbContext database) : Endpoint<DeleteLoan
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/loans/{@Id}", x => new {x.Id});
|
Delete("/loans/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GetAllLoanEndpoint(LibraryDbContext database) : EndpointWithoutRequ
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/loans");
|
Get("/loans");
|
||||||
Roles("viewer", "admin", "librarian"); }
|
Roles("viewer", "admin", "librarian"); }
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class GetLoanEndpoint(LibraryDbContext database) : Endpoint<GetLoanReques
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/loans/{@Id}", x => new {x.Id});
|
Get("/loans/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian"); }
|
Roles("viewer", "admin", "librarian"); }
|
||||||
|
|
||||||
public override async Task HandleAsync(GetLoanRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetLoanRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class PatchLoanEndpoint(LibraryDbContext database) : Endpoint<PatchLoanDt
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Patch("/api/loans/{@Id}/EffectiveReturningDate", x => new {x.Id});
|
Patch("/loans/{@Id}/EffectiveReturningDate", x => new {x.Id});
|
||||||
Roles("admin", "librarian");
|
Roles("admin", "librarian");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateLoanEndpoint(LibraryDbContext database) : Endpoint<UpdateLoan
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/loans/{@Id}", x => new {x.Id});
|
Put("/loans/{@Id}", x => new {x.Id});
|
||||||
Roles("admin", "librarian");
|
Roles("admin", "librarian");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class CreateLoginEndpoint(LibraryDbContext database) : Endpoint<CreateLog
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/logins");
|
Post("/logins");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class DeleteLoginEndpoint(LibraryDbContext database) : Endpoint<DeleteLog
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/logins/{@Id}", x => new {x.Id});
|
Delete("/logins/{@Id}", x => new {x.Id});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteLoginRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteLoginRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetAllLoginEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/logins");
|
Get("/logins");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class GetLoginEndpoint(LibraryDbContext database) : Endpoint<GetLoginRequ
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/logins/{@Id}", x => new {x.Id});
|
Get("/logins/{@Id}", x => new {x.Id});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetLoginRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetLoginRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class UpdateLoginEndpoint(LibraryDbContext database) : Endpoint<UpdateLog
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/logins/{@Id}", x => new {x.Id});
|
Put("/logins/{@Id}", x => new {x.Id});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateLoginDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateLoginDto req, CancellationToken ct)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class UserLoginEndpoint(LibraryDbContext database) : Endpoint<ConnectLogi
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/login");
|
Post("/login");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class CreateUserEndpoint(LibraryDbContext database) : Endpoint<CreateUser
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/users");
|
Post("/users");
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class DeleteUserEndpoint(LibraryDbContext database) : Endpoint<DeleteUser
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/users/{@Id}", x => new {x.Id});
|
Delete("/users/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetAllUsersEndpoint(LibraryDbContext database) : EndpointWithoutReq
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/users");
|
Get("/users");
|
||||||
Roles("viewer", "admin", "librarian"); }
|
Roles("viewer", "admin", "librarian"); }
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class GetUserEndpoint(LibraryDbContext database) : Endpoint<GetUserReques
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/users/{@Id}", x => new {x.Id});
|
Get("/users/{@Id}", x => new {x.Id});
|
||||||
Roles("viewer", "admin", "librarian"); }
|
Roles("viewer", "admin", "librarian"); }
|
||||||
|
|
||||||
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateUserEndpoint(LibraryDbContext database) : Endpoint<UpdateUser
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/users/{@Id}", x => new {x.Id});
|
Put("/users/{@Id}", x => new {x.Id});
|
||||||
Roles("admin");
|
Roles("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ builder.Services
|
|||||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
|
||||||
.AddAuthorization()
|
.AddAuthorization()
|
||||||
.AddFastEndpoints()
|
.AddFastEndpoints()
|
||||||
.SwaggerDocument();
|
.SwaggerDocument(options =>
|
||||||
|
{
|
||||||
|
options.ShortSchemaNames = true;
|
||||||
|
});
|
||||||
|
|
||||||
// On ajoute ici la configuration de la base de données
|
// On ajoute ici la configuration de la base de données
|
||||||
builder.Services.AddDbContext<LibraryDbContext>();
|
builder.Services.AddDbContext<LibraryDbContext>();
|
||||||
@@ -19,7 +22,10 @@ builder.Services.AddDbContext<LibraryDbContext>();
|
|||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
app.UseAuthentication()
|
app.UseAuthentication()
|
||||||
.UseAuthorization()
|
.UseAuthorization()
|
||||||
.UseFastEndpoints()
|
.UseFastEndpoints(options =>
|
||||||
|
{
|
||||||
|
options.Endpoints.RoutePrefix = "API";
|
||||||
|
})
|
||||||
.UseSwaggerGen();
|
.UseSwaggerGen();
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|||||||
Reference in New Issue
Block a user