AtmoType is a font sharing website through ATProto.

[be] add example endpoint

Changed files
+58 -1
AtmoType
+1
AtmoType/AtmoType.csproj
··· 7 7 </PropertyGroup> 8 8 9 9 <ItemGroup> 10 + <PackageReference Include="FastEndpoints" Version="7.1.1" /> 10 11 <PackageReference Include="FishyFlip" Version="4.2.0" /> 11 12 </ItemGroup> 12 13
+24
AtmoType/Endpoints/Example/Example.cs
··· 1 + namespace AtmoType.Endpoints.Example; 2 + 3 + public class ExampleRequest 4 + { 5 + public string? Name { get; set; } 6 + } 7 + 8 + public class ExampleResponse 9 + { 10 + public string Hello { get; set; } = string.Empty; 11 + } 12 + 13 + public class Example : XrpcQuery<ExampleRequest, ExampleResponse> 14 + { 15 + public override string Nsid => "win.atmotype.example.example"; 16 + 17 + public override async Task<ExampleResponse> ExecuteAsync(ExampleRequest req, CancellationToken ct) 18 + { 19 + return new ExampleResponse 20 + { 21 + Hello = "world" 22 + }; 23 + } 24 + }
+4 -1
AtmoType/Program.cs
··· 1 + using FastEndpoints; 2 + 1 3 var builder = WebApplication.CreateBuilder(args); 4 + builder.Services.AddFastEndpoints(); 2 5 var app = builder.Build(); 3 6 7 + app.UseFastEndpoints(); 4 8 app.MapGet("/", () => "Hello World!"); 5 - 6 9 app.Run();
+29
AtmoType/XrpcBase.cs
··· 1 + using FastEndpoints; 2 + 3 + namespace AtmoType; 4 + 5 + public abstract class XrpcQuery<TRequest, TResponse> : Endpoint<TRequest, TResponse> 6 + where TRequest : notnull 7 + where TResponse : notnull 8 + { 9 + public abstract string Nsid { get; } 10 + 11 + public override void Configure() 12 + { 13 + Get($"/xrpc/{Nsid}"); 14 + AllowAnonymous(); // TODO: Better auth support 15 + } 16 + } 17 + 18 + public abstract class XrpcProcedure<TRequest, TResponse> : Endpoint<TRequest, TResponse> 19 + where TRequest : notnull 20 + where TResponse : notnull 21 + { 22 + public abstract string Nsid { get; } 23 + 24 + public override void Configure() 25 + { 26 + Post($"/xrpc/{Nsid}"); 27 + AllowAnonymous(); // TODO: Better auth support 28 + } 29 + }