Rystem.RepositoryFramework.Api.Server 6.0.0-rc.3

This is a prerelease version of Rystem.RepositoryFramework.Api.Server.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Rystem.RepositoryFramework.Api.Server --version 6.0.0-rc.3
                    
NuGet\Install-Package Rystem.RepositoryFramework.Api.Server -Version 6.0.0-rc.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rystem.RepositoryFramework.Api.Server" Version="6.0.0-rc.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rystem.RepositoryFramework.Api.Server" Version="6.0.0-rc.3" />
                    
Directory.Packages.props
<PackageReference Include="Rystem.RepositoryFramework.Api.Server" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Rystem.RepositoryFramework.Api.Server --version 6.0.0-rc.3
                    
#r "nuget: Rystem.RepositoryFramework.Api.Server, 6.0.0-rc.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Rystem.RepositoryFramework.Api.Server&version=6.0.0-rc.3&prerelease
                    
Install Rystem.RepositoryFramework.Api.Server as a Cake Addin
#tool nuget:?package=Rystem.RepositoryFramework.Api.Server&version=6.0.0-rc.3&prerelease
                    
Install Rystem.RepositoryFramework.Api.Server as a Cake Tool

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 Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.1 20,446 5/2/2025
9.0.33 137 4/30/2025
9.0.32 186,565 4/15/2025
9.0.31 5,738 4/2/2025
9.0.30 88,770 3/26/2025
9.0.29 8,917 3/18/2025
9.0.28 153 3/17/2025
9.0.27 150 3/16/2025
9.0.26 163 3/13/2025
9.0.25 52,041 3/9/2025
9.0.21 272 3/6/2025
9.0.20 19,503 3/6/2025
9.0.19 228 3/6/2025
9.0.18 211 3/4/2025
9.0.17 116 3/1/2025
9.0.16 108 3/1/2025
9.0.15 75,453 2/22/2025
9.0.14 22,513 2/18/2025
9.0.13 125 2/9/2025
9.0.12 217,643 1/13/2025
9.0.11 23,960 1/9/2025
9.0.10 86 1/9/2025
9.0.9 3,959 1/7/2025
9.0.8 12,455 1/6/2025
9.0.7 101 1/6/2025
9.0.4 92,256 12/23/2024
9.0.3 112 12/22/2024
9.0.2 10,654 12/21/2024
9.0.1 1,148 12/21/2024
9.0.0 173,017 11/16/2024
9.0.0-rc.1 88 10/18/2024
6.2.0 218,999 10/9/2024
6.1.1 134 10/9/2024
6.1.0 47,925 9/29/2024
6.0.24 164 9/11/2024
6.0.23 340,124 7/18/2024
6.0.21 152 6/18/2024
6.0.20 727,758 6/16/2024
6.0.19 30,376 6/14/2024
6.0.18 150 6/14/2024
6.0.17 129 6/14/2024
6.0.16 49,990 6/10/2024
6.0.15 139 6/9/2024
6.0.14 94,264 5/24/2024
6.0.13 162 5/23/2024
6.0.12 125 5/23/2024
6.0.11 142 5/20/2024
6.0.9 114 5/20/2024
6.0.7 106 5/18/2024
6.0.6 161 5/10/2024
6.0.5 156 5/10/2024
6.0.4 549,818 4/3/2024
6.0.3 1,431 3/25/2024
6.0.2 393,584 3/11/2024
6.0.0 1,171,163 11/21/2023
6.0.0-rc.6 120 10/25/2023
6.0.0-rc.5 95 10/25/2023
6.0.0-rc.4 89 10/23/2023
6.0.0-rc.3 81 10/19/2023
6.0.0-rc.2 91 10/18/2023
6.0.0-rc.1 85 10/16/2023
5.0.20 638,592 9/25/2023
5.0.19 944 9/10/2023
5.0.18 921 9/6/2023
5.0.17 904 9/6/2023
5.0.16 968 9/5/2023
5.0.15 920 9/5/2023
5.0.14 883 9/5/2023
5.0.13 882 9/1/2023
5.0.12 915 8/31/2023
5.0.11 887 8/30/2023
5.0.10 901 8/29/2023
5.0.9 938 8/24/2023
5.0.8 950 8/24/2023
5.0.7 450,413 8/23/2023
5.0.6 18,260 8/21/2023
5.0.5 5,088 8/21/2023
5.0.4 949 8/16/2023
5.0.3 213,328 8/2/2023
5.0.2 2,605 8/2/2023
5.0.1 12,408 8/1/2023
5.0.0 12,682 7/31/2023
4.1.26 141,459 7/20/2023
4.1.25 25,445 7/16/2023
4.1.24 398,537 6/13/2023
4.1.23 46,495 6/13/2023
4.1.22 130,319 5/30/2023
4.1.21 56,233 5/20/2023
4.1.20 405,416 4/19/2023
4.1.19 96,236 3/20/2023
4.1.18 1,126 3/20/2023
4.1.17 1,108 3/16/2023
4.1.16 1,116 3/16/2023
4.1.15 1,072 3/15/2023
4.1.14 1,657 3/9/2023
4.1.13 1,100 3/7/2023
4.1.12 1,317 2/10/2023
4.1.11 1,185 1/26/2023
4.1.10 1,171 1/22/2023
4.1.9 1,154 1/20/2023
4.1.8 1,122 1/18/2023
4.1.7 1,326 1/18/2023
4.1.6 1,189 1/17/2023
4.1.1 1,185 1/4/2023
4.1.0 1,238 1/1/2023
3.1.5 1,167 12/21/2022
3.1.3 1,200 12/12/2022
3.1.2 1,154 12/7/2022
3.1.1 1,155 12/7/2022
3.1.0 1,222 12/2/2022
3.0.29 1,201 12/1/2022
3.0.28 1,186 12/1/2022
3.0.27 1,387 11/23/2022
3.0.25 1,241 11/23/2022
3.0.24 1,215 11/18/2022
3.0.23 1,202 11/18/2022
3.0.22 1,248 11/15/2022
3.0.21 1,252 11/14/2022
3.0.20 1,233 11/13/2022
3.0.19 1,472 11/2/2022
3.0.18 1,234 11/2/2022
3.0.17 1,237 10/29/2022
3.0.16 1,249 10/29/2022
3.0.15 1,213 10/29/2022
3.0.14 1,322 10/24/2022
3.0.13 1,296 10/24/2022
3.0.12 1,325 10/17/2022
3.0.11 1,302 10/10/2022
3.0.10 1,339 10/6/2022
3.0.9 1,272 10/6/2022
3.0.8 1,255 10/6/2022
3.0.7 1,280 10/6/2022
3.0.6 1,251 10/5/2022
3.0.5 1,265 10/5/2022
3.0.4 1,230 10/5/2022
3.0.3 1,273 10/3/2022
3.0.2 1,277 9/30/2022
3.0.1 1,264 9/29/2022
2.0.17 1,296 9/29/2022
2.0.16 1,258 9/27/2022
2.0.15 1,374 9/27/2022
2.0.14 1,308 9/26/2022
2.0.13 1,347 9/26/2022
2.0.12 1,322 9/26/2022
2.0.11 1,272 9/25/2022
2.0.10 1,340 9/25/2022
2.0.9 1,343 9/22/2022
2.0.8 1,324 9/22/2022
2.0.6 1,275 9/20/2022
2.0.5 1,299 9/20/2022
2.0.4 1,296 9/20/2022
2.0.2 1,307 9/20/2022
2.0.1 1,393 9/13/2022
2.0.0 1,299 8/19/2022
1.1.24 1,331 7/30/2022
1.1.23 1,298 7/29/2022
1.1.22 1,292 7/29/2022
1.1.21 1,361 7/29/2022
1.1.20 1,328 7/29/2022
1.1.19 1,392 7/27/2022
1.1.17 1,284 7/27/2022
1.1.16 1,332 7/26/2022
1.1.15 1,351 7/25/2022
1.1.14 1,337 7/25/2022
1.1.13 1,287 7/22/2022
1.1.12 1,374 7/19/2022
1.1.11 1,352 7/19/2022
1.1.10 1,344 7/19/2022
1.1.9 1,333 7/19/2022
1.1.8 1,352 7/18/2022
1.1.7 1,329 7/18/2022
1.1.6 1,335 7/18/2022
1.1.5 1,318 7/17/2022
1.1.4 1,362 7/17/2022
1.1.3 1,354 7/17/2022
1.1.2 1,368 7/17/2022
1.1.0 1,347 7/17/2022
1.0.2 1,313 7/15/2022
1.0.1 1,279 7/15/2022
1.0.0 1,326 7/8/2022
0.10.7 1,352 7/7/2022
0.10.2 1,373 7/2/2022
0.10.1 1,295 7/1/2022
0.10.0 1,302 7/1/2022
0.9.11 1,345 6/29/2022
0.9.10 1,345 6/20/2022
0.9.9 1,308 6/11/2022
0.9.7 1,362 6/9/2022
0.9.6 1,315 6/5/2022
0.9.5 1,336 6/3/2022
0.9.4 1,329 6/3/2022
0.9.3 1,317 6/3/2022
0.9.2 1,315 5/31/2022
0.9.1 1,294 5/31/2022
0.9.0 1,294 5/31/2022