+1
AtmoType/AtmoType.csproj
+1
AtmoType/AtmoType.csproj
+24
AtmoType/Endpoints/Example/Example.cs
+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
+4
-1
AtmoType/Program.cs
+29
AtmoType/XrpcBase.cs
+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
+
}