Rystem.RepositoryFramework.Api.Server
9.0.0-rc.1
See the version list below for details.
dotnet add package Rystem.RepositoryFramework.Api.Server --version 9.0.0-rc.1
NuGet\Install-Package Rystem.RepositoryFramework.Api.Server -Version 9.0.0-rc.1
<PackageReference Include="Rystem.RepositoryFramework.Api.Server" Version="9.0.0-rc.1" />
paket add Rystem.RepositoryFramework.Api.Server --version 9.0.0-rc.1
#r "nuget: Rystem.RepositoryFramework.Api.Server, 9.0.0-rc.1"
// Install Rystem.RepositoryFramework.Api.Server as a Cake Addin #addin nuget:?package=Rystem.RepositoryFramework.Api.Server&version=9.0.0-rc.1&prerelease // Install Rystem.RepositoryFramework.Api.Server as a Cake Tool #tool nuget:?package=Rystem.RepositoryFramework.Api.Server&version=9.0.0-rc.1&prerelease
What is Rystem?
Api auto-generated
In your web application you have only to add one row after service build.
services.AddApiFromRepositoryFramework()
.WithDescriptiveName("Repository Api")
.WithPath(Path)
.WithSwagger()
.WithVersion(Version)
.WithDocumentation()
.WithDefaultCors("http://example.com");
var app = builder.Build();
app.UseApiFromRepositoryFramework()
.WithNoAuthorization();
public static ApiAuthorizationBuilder UseApiFromRepositoryFramework<TEndpointRouteBuilder>(
this TEndpointRouteBuilder app,
string startingPath = "api")
where TEndpointRouteBuilder : IEndpointRouteBuilder
You may add api for each service by
public static ApiAuthorizationBuilder UseApiForRepository<T>(this IEndpointRouteBuilder app,
string startingPath = "api")
Startup example
In the example below you may find the setup of three populated repositories, two of them are of the same kind (SuperUser). The SuperiorUser will be added to the app but will be not exposed as Api cause the SetNotExposable() method. Futhermore, we are adding a configuration for AAD to implement authentication on api.
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddRepository<SuperUser, string>(settins =>
{
settins.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(120, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com");
});
settins.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(2, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com");
}, "inmemory");
});
builder.Services.AddRepository<SuperiorUser, string>(settings =>
{
settings.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(120, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com")
.WithPattern(x => x.Value!.Port, @"[1-9]{3,4}");
});
settings.SetNotExposable();
});
builder.Services.AddApiFromRepositoryFramework()
.WithDescriptiveName("Repository Api")
.WithPath(Path)
.WithSwagger()
.WithVersion(Version)
.WithDocumentation()
.WithDefaultCors("http://example.com");
var app = builder.Build();
await app.Services.WarmUpAsync();
app.UseHttpsRedirection();
app.UseApiFromRepositoryFramework()
.WithDefaultAuthorization();
app.Run();
No Authorization flow - default
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddRepository<SuperUser, string>(settins =>
{
settins.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(120, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com");
});
settins.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(2, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com");
}, "inmemory");
});
builder.Services.AddRepository<SuperiorUser, string>(settings =>
{
settings.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(120, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com")
.WithPattern(x => x.Value!.Port, @"[1-9]{3,4}");
});
settings.SetNotExposable();
});
builder.Services.AddApiFromRepositoryFramework()
.WithDescriptiveName("Repository Api")
.WithPath(Path)
.WithSwagger()
.WithVersion(Version)
.WithDocumentation()
.WithDefaultCors("http://example.com");
var app = builder.Build();
await app.Services.WarmUpAsync();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseApiFromRepositoryFramework()
.WithNoAuthorization();
app.Run();
Authorization flow - custom policies
You may configure the scoper for each method of your repository and for each repository, as you wish.
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddRepository<SuperUser, string>(settins =>
{
settins.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(120, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com");
});
settins.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(2, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com");
}, "inmemory");
});
builder.Services.AddRepository<SuperiorUser, string>(settings =>
{
settings.WithInMemory(builder =>
{
builder
.PopulateWithRandomData(120, 5)
.WithPattern(x => x.Value!.Email, @"[a-z]{5,10}@gmail\.com")
.WithPattern(x => x.Value!.Port, @"[1-9]{3,4}");
});
settings.SetNotExposable();
});
builder.Services.AddAuthorization(
options =>
{
options.AddPolicy("NormalUser", x =>
{
x.RequireClaim(ClaimTypes.Name);
});
options.AddPolicy("SuperAdmin", x =>
{
x.RequireRole("SuperAdmin");
});
});
builder.Services.AddApiFromRepositoryFramework()
.WithDescriptiveName("Repository Api")
.WithPath(Path)
.WithSwagger()
.WithVersion(Version)
.WithDocumentation()
.WithDefaultCors("http://example.com");
var app = builder.Build();
await app.Services.WarmUpAsync();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/healthz");
endpoints.UseApiFromRepository<SuperUser>()
.SetPolicyForCommand()
.With("SuperAdmin")
.Build();
endpoints.UseApiFromRepositoryFramework()
.SetPolicyForAll()
.With("NormalUser")
.And()
.SetPolicy(RepositoryMethods.Insert)
.With("SuperAdmin")
.And()
.SetPolicy(RepositoryMethods.Update)
.With("SuperAdmin")
.Build();
endpoints
.MapControllers();
});
app.Run();
In this example, I'm configuring a policy named "NormalUser" for all methods and all repositories, and a policy named "SuperAdmin" for the methods Insert and Update for all repositories and for the command (Insert, Updated and Delete) of SuperUser repository. You can customize it repository for repository, using UseApiFromRepository<T>() method.
Sample of filter usage when you use the api directly
All the requests are basic requests, the strangest request is only the query and you must use the Linq query. You may find some examples down below:
ƒ => (((ƒ.X == "dasda") AndAlso ƒ.X.Contains("dasda")) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32)))
ƒ => ((((ƒ.X == "dasda") AndAlso ƒ.Sol) AndAlso ƒ.X.Contains("dasda")) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32)))
ƒ => (((((ƒ.X == "dasda") AndAlso ƒ.Sol) AndAlso ƒ.X.Contains("dasda")) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32))) AndAlso ((ƒ.Type == 1) OrElse (ƒ.Type == 2)))
ƒ => (ƒ.Type == 2)
ƒ => (((((ƒ.X == "dasda") AndAlso ƒ.Sol) AndAlso (ƒ.X.Contains("dasda") OrElse ƒ.Sol.Equals(True))) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32))) AndAlso ((ƒ.Type == 1) OrElse (ƒ.Type == 2)))
ƒ => ((((((ƒ.X == "dasda") AndAlso ƒ.Samules.Any(x => (x == "ccccde"))) AndAlso ƒ.Sol) AndAlso (ƒ.X.Contains("dasda") OrElse ƒ.Sol.Equals(True))) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32))) AndAlso ((ƒ.Type == 1) OrElse (ƒ.Type == 2)))
ƒ => (ƒ.ExpirationTime > Convert.ToDateTime("7/6/2022 9:48:56 AM"))
ƒ => (ƒ.TimeSpan > new TimeSpan(1000 as long))
ƒ => Not(ƒ.Inside.Inside.A.Equals("dasdad"))
ƒ => Not(String.IsNullOrWhiteSpace(ƒ.Inside.Inside.A))
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
-
net9.0
- Rystem.RepositoryFramework.Abstractions (>= 9.0.0-rc.1)
- Swashbuckle.AspNetCore (>= 6.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 147,460 | 11/16/2024 |
9.0.0-rc.1 | 77 | 10/18/2024 |
6.2.0 | 218,976 | 10/9/2024 |
6.1.1 | 106 | 10/9/2024 |
6.1.0 | 47,904 | 9/29/2024 |
6.0.24 | 142 | 9/11/2024 |
6.0.23 | 340,101 | 7/18/2024 |
6.0.21 | 124 | 6/18/2024 |
6.0.20 | 727,741 | 6/16/2024 |
6.0.19 | 30,358 | 6/14/2024 |
6.0.18 | 132 | 6/14/2024 |
6.0.17 | 110 | 6/14/2024 |
6.0.16 | 49,973 | 6/10/2024 |
6.0.15 | 123 | 6/9/2024 |
6.0.14 | 94,244 | 5/24/2024 |
6.0.13 | 147 | 5/23/2024 |
6.0.12 | 109 | 5/23/2024 |
6.0.11 | 122 | 5/20/2024 |
6.0.9 | 96 | 5/20/2024 |
6.0.7 | 89 | 5/18/2024 |
6.0.6 | 144 | 5/10/2024 |
6.0.5 | 140 | 5/10/2024 |
6.0.4 | 549,804 | 4/3/2024 |
6.0.3 | 1,307 | 3/25/2024 |
6.0.2 | 393,569 | 3/11/2024 |
6.0.0 | 1,171,157 | 11/21/2023 |
6.0.0-rc.6 | 114 | 10/25/2023 |
6.0.0-rc.5 | 88 | 10/25/2023 |
6.0.0-rc.4 | 83 | 10/23/2023 |
6.0.0-rc.3 | 72 | 10/19/2023 |
6.0.0-rc.2 | 85 | 10/18/2023 |
6.0.0-rc.1 | 79 | 10/16/2023 |
5.0.20 | 638,586 | 9/25/2023 |
5.0.19 | 931 | 9/10/2023 |
5.0.18 | 911 | 9/6/2023 |
5.0.17 | 893 | 9/6/2023 |
5.0.16 | 958 | 9/5/2023 |
5.0.15 | 901 | 9/5/2023 |
5.0.14 | 874 | 9/5/2023 |
5.0.13 | 872 | 9/1/2023 |
5.0.12 | 906 | 8/31/2023 |
5.0.11 | 878 | 8/30/2023 |
5.0.10 | 891 | 8/29/2023 |
5.0.9 | 911 | 8/24/2023 |
5.0.8 | 931 | 8/24/2023 |
5.0.7 | 450,402 | 8/23/2023 |
5.0.6 | 18,250 | 8/21/2023 |
5.0.5 | 5,071 | 8/21/2023 |
5.0.4 | 938 | 8/16/2023 |
5.0.3 | 213,317 | 8/2/2023 |
5.0.2 | 2,595 | 8/2/2023 |
5.0.1 | 12,389 | 8/1/2023 |
5.0.0 | 12,671 | 7/31/2023 |
4.1.26 | 141,447 | 7/20/2023 |
4.1.25 | 25,434 | 7/16/2023 |
4.1.24 | 398,517 | 6/13/2023 |
4.1.23 | 46,476 | 6/13/2023 |
4.1.22 | 130,288 | 5/30/2023 |
4.1.21 | 56,215 | 5/20/2023 |
4.1.20 | 405,398 | 4/19/2023 |
4.1.19 | 96,217 | 3/20/2023 |
4.1.18 | 1,107 | 3/20/2023 |
4.1.17 | 1,090 | 3/16/2023 |
4.1.16 | 1,095 | 3/16/2023 |
4.1.15 | 1,054 | 3/15/2023 |
4.1.14 | 1,638 | 3/9/2023 |
4.1.13 | 1,079 | 3/7/2023 |
4.1.12 | 1,280 | 2/10/2023 |
4.1.11 | 1,161 | 1/26/2023 |
4.1.10 | 1,148 | 1/22/2023 |
4.1.9 | 1,131 | 1/20/2023 |
4.1.8 | 1,099 | 1/18/2023 |
4.1.7 | 1,303 | 1/18/2023 |
4.1.6 | 1,165 | 1/17/2023 |
4.1.1 | 1,163 | 1/4/2023 |
4.1.0 | 1,217 | 1/1/2023 |
3.1.5 | 1,144 | 12/21/2022 |
3.1.3 | 1,177 | 12/12/2022 |
3.1.2 | 1,131 | 12/7/2022 |
3.1.1 | 1,132 | 12/7/2022 |
3.1.0 | 1,196 | 12/2/2022 |
3.0.29 | 1,176 | 12/1/2022 |
3.0.28 | 1,161 | 12/1/2022 |
3.0.27 | 1,361 | 11/23/2022 |
3.0.25 | 1,207 | 11/23/2022 |
3.0.24 | 1,189 | 11/18/2022 |
3.0.23 | 1,177 | 11/18/2022 |
3.0.22 | 1,222 | 11/15/2022 |
3.0.21 | 1,229 | 11/14/2022 |
3.0.20 | 1,206 | 11/13/2022 |
3.0.19 | 1,437 | 11/2/2022 |
3.0.18 | 1,208 | 11/2/2022 |
3.0.17 | 1,210 | 10/29/2022 |
3.0.16 | 1,224 | 10/29/2022 |
3.0.15 | 1,188 | 10/29/2022 |
3.0.14 | 1,294 | 10/24/2022 |
3.0.13 | 1,271 | 10/24/2022 |
3.0.12 | 1,299 | 10/17/2022 |
3.0.11 | 1,277 | 10/10/2022 |
3.0.10 | 1,312 | 10/6/2022 |
3.0.9 | 1,243 | 10/6/2022 |
3.0.8 | 1,225 | 10/6/2022 |
3.0.7 | 1,253 | 10/6/2022 |
3.0.6 | 1,225 | 10/5/2022 |
3.0.5 | 1,239 | 10/5/2022 |
3.0.4 | 1,205 | 10/5/2022 |
3.0.3 | 1,246 | 10/3/2022 |
3.0.2 | 1,250 | 9/30/2022 |
3.0.1 | 1,237 | 9/29/2022 |
2.0.17 | 1,251 | 9/29/2022 |
2.0.16 | 1,230 | 9/27/2022 |
2.0.15 | 1,346 | 9/27/2022 |
2.0.14 | 1,281 | 9/26/2022 |
2.0.13 | 1,320 | 9/26/2022 |
2.0.12 | 1,295 | 9/26/2022 |
2.0.11 | 1,236 | 9/25/2022 |
2.0.10 | 1,314 | 9/25/2022 |
2.0.9 | 1,317 | 9/22/2022 |
2.0.8 | 1,298 | 9/22/2022 |
2.0.6 | 1,249 | 9/20/2022 |
2.0.5 | 1,273 | 9/20/2022 |
2.0.4 | 1,267 | 9/20/2022 |
2.0.2 | 1,282 | 9/20/2022 |
2.0.1 | 1,366 | 9/13/2022 |
2.0.0 | 1,274 | 8/19/2022 |
1.1.24 | 1,302 | 7/30/2022 |
1.1.23 | 1,272 | 7/29/2022 |
1.1.22 | 1,266 | 7/29/2022 |
1.1.21 | 1,335 | 7/29/2022 |
1.1.20 | 1,300 | 7/29/2022 |
1.1.19 | 1,363 | 7/27/2022 |
1.1.17 | 1,257 | 7/27/2022 |
1.1.16 | 1,305 | 7/26/2022 |
1.1.15 | 1,323 | 7/25/2022 |
1.1.14 | 1,311 | 7/25/2022 |
1.1.13 | 1,259 | 7/22/2022 |
1.1.12 | 1,347 | 7/19/2022 |
1.1.11 | 1,325 | 7/19/2022 |
1.1.10 | 1,294 | 7/19/2022 |
1.1.9 | 1,305 | 7/19/2022 |
1.1.8 | 1,324 | 7/18/2022 |
1.1.7 | 1,301 | 7/18/2022 |
1.1.6 | 1,306 | 7/18/2022 |
1.1.5 | 1,291 | 7/17/2022 |
1.1.4 | 1,317 | 7/17/2022 |
1.1.3 | 1,327 | 7/17/2022 |
1.1.2 | 1,331 | 7/17/2022 |
1.1.0 | 1,320 | 7/17/2022 |
1.0.2 | 1,286 | 7/15/2022 |
1.0.1 | 1,253 | 7/15/2022 |
1.0.0 | 1,300 | 7/8/2022 |
0.10.7 | 1,324 | 7/7/2022 |
0.10.2 | 1,345 | 7/2/2022 |
0.10.1 | 1,268 | 7/1/2022 |
0.10.0 | 1,275 | 7/1/2022 |
0.9.11 | 1,318 | 6/29/2022 |
0.9.10 | 1,318 | 6/20/2022 |
0.9.9 | 1,281 | 6/11/2022 |
0.9.7 | 1,336 | 6/9/2022 |
0.9.6 | 1,287 | 6/5/2022 |
0.9.5 | 1,309 | 6/3/2022 |
0.9.4 | 1,301 | 6/3/2022 |
0.9.3 | 1,274 | 6/3/2022 |
0.9.2 | 1,287 | 5/31/2022 |
0.9.1 | 1,267 | 5/31/2022 |
0.9.0 | 1,267 | 5/31/2022 |