Skip to content
sommmenPublic

About

C# api wrapper for https://lightr.nl/ a SAAS to send handwritten cards via an API

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

138 Commits

Folders and files

Repository files navigation

lightr

.NET .NET

C# api for https://lightr.nl/ a SAAS to send handwritten cards via an API.

Getting started

Install the package:

dotnet add package Lightr

Then simply add the ILightrClient to your DI using:

services.AddLightr("my-token");

Or:

services
    .AddLightr((provider, options) =>
    {
        var token = provider.GetRequiredService<ILightrSettings>().ApiKey;
        options.UseToken(token);
    });

Then use this service;

public class MyAwesomeApp
{
    private readonly ILightrClient _lightrClient;

    public MyAwesomeApp(ILightrClient lightrClient)
    {
        _lightrClient = lightrClient;
    }

    public async Task MyBusinessMethod(CancellationToken cancellationToken = default)
    {
        await _lightrClient.MeAsync(cancellationToken);
    }
}

For more information check the sample.

Rate Limits

A LightrRateLimitedHandler is added by default which handles the rate limits of the API. One sliding-window limiter is shared per registration (so it survives IHttpClientFactory handler rotation) and requests are delayed when the limit is reached. It defaults to 100 requests per 60 seconds, below the server's 120 per minute. A server 429 with a Retry-After of at most 60 seconds is waited out and retried once.

services.Configure<LightrRateLimitOptions>(o =>
{
    o.PermitLimit = 100;
    o.Window = TimeSpan.FromSeconds(60);
    o.QueueLimit = 120;
    o.MaxRetryAfter = TimeSpan.FromSeconds(60); // TimeSpan.Zero disables the 429 retry
});

Development

The library is generated from the upstream OpenAPI document and requires the .NET 10 SDK. Restore the repository-local tools before building:

dotnet tool restore
dotnet build

To refresh the checked-in OpenAPI document, run:

.\scripts\Refresh-OpenApi.ps1
dotnet build

The build automatically applies schema-corrections.overlay.yaml before NSwag generates the client. The overlay corrects known upstream schema defects, so no manual post-processing of the downloaded document is needed.

Dependency updates are handled by a self-hosted Renovate workflow; see docs/Renovate/Renovate.md for its triggers, automerge rules and troubleshooting.

Versioning and releasing

Versions are computed by Nerdbank.GitVersioning from version.json: <major>.<minor> comes from the file and the patch is the git height since that value last changed. Builds from main and from tags named X.Y.Z (no v prefix) are public versions; every other ref gets a -g<sha> prerelease suffix. CI and the deploy workflow therefore check out the full history (fetch-depth: 0).

To release, publish a GitHub release on a tag that matches the version nbgv get-version -v NuGetPackageVersion prints for the commit on main (for example 1.7.1). The deploy workflow builds that tag and pushes the package to nuget.org and GitHub Packages. To start a new minor or major line, bump version in version.json.

About

C# api wrapper for https://lightr.nl/ a SAAS to send handwritten cards via an API

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages