Tago.Extensions.AspnetCore.IndexesAsApi.MySql 6.0.0-preview-202501-11

This is a prerelease version of Tago.Extensions.AspnetCore.IndexesAsApi.MySql.
dotnet add package Tago.Extensions.AspnetCore.IndexesAsApi.MySql --version 6.0.0-preview-202501-11                
NuGet\Install-Package Tago.Extensions.AspnetCore.IndexesAsApi.MySql -Version 6.0.0-preview-202501-11                
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="Tago.Extensions.AspnetCore.IndexesAsApi.MySql" Version="6.0.0-preview-202501-11" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tago.Extensions.AspnetCore.IndexesAsApi.MySql --version 6.0.0-preview-202501-11                
#r "nuget: Tago.Extensions.AspnetCore.IndexesAsApi.MySql, 6.0.0-preview-202501-11"                
#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.
// Install Tago.Extensions.AspnetCore.IndexesAsApi.MySql as a Cake Addin
#addin nuget:?package=Tago.Extensions.AspnetCore.IndexesAsApi.MySql&version=6.0.0-preview-202501-11&prerelease

// Install Tago.Extensions.AspnetCore.IndexesAsApi.MySql as a Cake Tool
#tool nuget:?package=Tago.Extensions.AspnetCore.IndexesAsApi.MySql&version=6.0.0-preview-202501-11&prerelease                

Indexes-As-Api for MySql

A dynamic MySql API routes for ASP.NET Core

Welcome to the Dynamic MySql API Routes package for ASP.NET Core! This innovative package aims to streamline the development process by automatically generating API routes based on MySqlDB indexes. If you’re an ASP.NET Core developer working with MySqlDB, this package will be a game-changer for you. It allows for the dynamic creation of routes without the need for manual configuration, saving you time and reducing the potential for errors.

  • Dynamic Route Generation: Automatically creates API routes based on MySqlDB indexes.
  • Paging Support: Configurable paging options to handle large datasets efficiently.
  • Flexible Configuration: Easily manage settings through appsettings.json.

Table of Contents

Introduction

In the fast-paced world of software development, efficiency and flexibility are paramount. As applications grow in complexity, managing API routes can become a daunting task, especially when dealing with a large number of collections and indexes. Traditional methods often require manual configuration, which can be both time-consuming and error-prone.

The Dynamic MySql API Routes package addresses this challenge by leveraging the power of MySqlDB indexes to auto-generate routes dynamically. This means that as your MySqlDB schema evolves, your API routes are automatically updated, ensuring that your application remains in sync with your database structure.

Key Benefits

1. Automatic Route Generation: One of the standout features of this package is its ability to automatically generate API routes based on MySqlDB indexes. This eliminates the need for manual route configuration, allowing to focus on more critical aspects of their application.

2. Enhanced Productivity: By automating the route generation process, this package significantly enhances productivity. With fewer manual configurations to manage, you can allocate more time to implementing features and improving the overall quality of the application.

3. Improved Consistency: Manual configuration is susceptible to human error, which can lead to inconsistencies and bugs. Automatic route generation ensures that routes are consistently defined based on the underlying MySqlDB schema, reducing the risk of errors and improving the stability of your application.

4. Flexibility and Scalability: The package is designed to handle applications of varying sizes and complexities. Whether you're working on a small project or a large-scale enterprise application, Dynamic MySql API Routes can easily scale to meet your needs. It supports multiple MySqlDB collections and indexes, providing a flexible solution for dynamic API routing.

5. Simplified Maintenance: As your application grows and evolves, maintaining API routes can become a cumbersome task. With dynamic route generation, updates to your MySqlDB schema are automatically reflected in your API routes, simplifying maintenance and reducing the overhead associated with manual updates.

6. Paging Support: Managing large datasets is a common challenge in modern applications. The package includes robust paging support, allowing to easily handle and paginate large collections of data. This ensures that your API remains performant and responsive, even when dealing with extensive datasets.

Installation

To install the Dynamic MySql API Routes package, use the following command:

dotnet add package Tago.Extensions.AspnetCore.IndexesAsApi.MySql

Usage

public static async Task Main(string[] args)
{
    var builder = WebApplication.CreateBuilder(args);

    builder.Services.AddAuthorization();

    MySqlSettings MySqlSettings = new MySqlSettings();
    builder.Configuration.GetSection("MySql").Bind(MySqlSettings);

    builder.Services.AddMySqlIndexesEndpoints(MySqlSettings)
        //.WithPersistance<IndexesPersistance>();
    ;


    var app = builder.Build();

    await app.UseMySqlIndexesEndpointsAsync(cfg => {
        //cfg.RoutesPrefix = "v1";
    }); 


    app.UseHttpsRedirection();

    app.UseAuthorization();

    app.Run();
}

Configuration

To configure the Dynamic MySql API Routes package, add the following section to your appsettings.json file:

"MySql": {
  //"CamelCaseModelProperties": false,
  //"RequireAuthorization": false, 
  //"Swagger": {
  //    "TitleTemplate": "{database}-{collection}"
  //},
  "IsPagingEnabled": true,
  "Paging": {
    "DefaultItemsPerPage": 100,
    "UsePagedResultModel": true,
    "PagedResultHeaders": {
      "TotalItemsHeader": "X-Total-Items",
      "PageNumberHeader": "X-Page-Number",
      "PageSizeHeader": "X-Page-Size"
    }
  },
  "ErrorMessages": {
    "UnIndexedQueryFilter": "Your search criteria isn't using any of the indexed fields"
  },
  "AutoGenerate": [
    {
      //"CamelCaseModelProperties": false,
      //"Swagger": {
      //    "TitleTemplate": "{database}-{collection}"
      //},
      "ConnectionString": ""Server=mySqlHost;User ID=test;Password=test;Database=world",
      "Database": "world",
      "Collections": [
        "city"
      ],
      "IsPagingEnabled": true,
      "Paging": {
        "IsPagingRequired": true,
        "DefaultItemsPerPage": 100,
        "UsePagedResultModel": false,
        "PagedResultHeaders": {
          "TotalItemsHeader": "X-Total-Items",
          "PageNumberHeader": "X-Page-Number",
          "PageSizeHeader": "X-Page-Size"
        }
      }
    },
    {
      "ConnectionString": ""Server=mySqlHost;User ID=test;Password=test;Database=world",
      "Database": "world",
      "Collections": [
        "countryLanguage"
      ],
      "Paging": {
        "IsPagingRequired": true
      }
    }
  ]
}

Configuration Table

Below is a table explaining each key in the configuration:

Key Description
MySql.RequireAuthorization Enables or disables authorization globally (default: true)
MySql.IsPagingEnabled Enables or disables paging for the entire configuration.
Paging.DefaultItemsPerPage Sets the default number of items per page when paging is enabled.
Paging.UsePagedResultModel Specifies whether to use a paged result model for responses.
Paging.PagedResultHeaders Defines custom headers for paging information in the response.
PagedResultHeaders.TotalItemsHeader Custom header name for the total number of items.
PagedResultHeaders.PageNumberHeader Custom header name for the current page number.
PagedResultHeaders.PageSizeHeader Custom header name for the page size.
AutoGenerate.ConnectionString MySqlDB connection string for the collection(s).
AutoGenerate.Database Name of the MySqlDB database.
AutoGenerate.Collections List of collections in the database to generate routes for.
AutoGenerate.RequireAuthorization Enables or disables authorization for the specific collection configuration.
AutoGenerate.IsPagingEnabled Enables or disables paging for the specific collection configuration.
AutoGenerate.Paging.IsPagingRequired Specifies whether paging is required for the specific collection configuration.
AutoGenerate.Paging.DefaultItemsPerPage Sets the default number of items per page for the specific collection.
AutoGenerate.Paging.UsePagedResultModel Specifies whether to use a paged result model for the specific collection.
AutoGenerate.Paging.PagedResultHeaders Defines custom headers for paging information for the specific collection.

Conclusion

In summary, the Dynamic MySql API Routes package is an essential tool for ASP.NET Core working with MySqlDB. By automating the route generation process, it enhances productivity, ensures consistency, and simplifies maintenance. This package can help you build scalable, efficient, and reliable applications with ease.

Embrace the future of dynamic API routing and elevate your development workflow with the Dynamic MySql API Routes package for ASP.NET Core!

Please review the provided documentation and let me know if you would like any changes or additions.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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
6.0.0-preview-202501-11 41 2/19/2025