Moved to Creators to features
This commit is contained in:
29
src/Web/Features/Creators/Handlers/GetCreatorByAlias.cs
Normal file
29
src/Web/Features/Creators/Handlers/GetCreatorByAlias.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using FastEndpoints;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Models;
|
||||
|
||||
namespace Hutopy.Web.Creators.Handlers;
|
||||
|
||||
public class GetCreatorByAlias(
|
||||
IIdentityService identityService)
|
||||
: EndpointWithoutRequest<UserModel?>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Options((o => o.WithTags("Creators")));
|
||||
Get("/api/creators/@{CreatorAlias}");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
CancellationToken ct)
|
||||
{
|
||||
var creatorAlias = Route<string>("CreatorAlias");
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(creatorAlias);
|
||||
|
||||
var user = await identityService.FindUserByCreatorAliasAsync(creatorAlias, ct);
|
||||
|
||||
await SendAsync(user, cancellation: ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user