GitHunt
TS

TS-NuGet-Packages/TS.Endpoints

TS.Endpoints is a lightweight modular routing library for ASP.NET Minimal APIs. Inspired by Carter, it enables clean, class-based endpoint organization without controllers.

TS.Endpoints

TS.Endpoints is a lightweight and modular endpoint registration library for ASP.NET Minimal APIs, inspired by Carter.
It lets you organize your API endpoints into clean, maintainable classes without using controllers.


๐Ÿš€ Features

  • โœ… Minimal API support
  • โœ… Modular design with IEndpoint interface
  • โœ… Automatic discovery via reflection
  • โœ… Fluent route mapping with MapEndpoints()
  • โœ… Support for single or multiple assemblies
  • โœ… Compatible with WithTags, WithName, and Swagger (optional extensions)

๐Ÿ“ฆ Installation

dotnet add package TS.Endpoints

โš™๏ธ Usage

1. Create an endpoint module:

using Microsoft.AspNetCore.Routing;
using TS.Endpoints;

public class ProductEndpoints : IEndpoint
{
    public void AddRoutes(IEndpointRouteBuilder builder)
    {
        var group = builder.MapGroup("/products").WithTags("Products");

        group.MapGet("/", () => Results.Ok("Get all products"))
              .WithSummary("GetAllProducts"); // => Optional

        group.MapPost("/", () => Results.Ok("Create product"))
              .WithSummary("CreateProduct"); // => Optional
    }
}

2. Register and map endpoints in Program.cs:

builder.Services.AddEndpoint(); // Scans current assembly

// or specify multiple assemblies
builder.Services.AddEndpoint(
    typeof(ProductEndpoints).Assembly,
    typeof(OtherEndpoints).Assembly
);

var app = builder.Build();
app.MapEndpoints();

๐Ÿค Contributing

Contributions are welcome via pull requests and issues.
If you find this useful, star the repo and share it โญ


๐Ÿ“„ License

MIT License