feat(api): expose the album endpoints

Eight routes under /albums covering the listing, the detail, the tracklist and
the owner-only writes, wired to the same validation filter and ErrorOr mapping
the playlists use.
This commit is contained in:
2026-07-20 20:13:40 +02:00
parent 712f130e1d
commit 68ec3a2aae
7 changed files with 260 additions and 0 deletions
@@ -0,0 +1,8 @@
namespace Musify.Api.Validators.Albums;
public static class AlbumReleaseYear
{
public const int Earliest = 1877;
public static int Latest => DateTime.UtcNow.Year + 1;
}
@@ -0,0 +1,21 @@
using FluentValidation;
using Musify.Api.DataTransferObjects.Albums;
namespace Musify.Api.Validators.Albums;
public sealed class CreateAlbumRequestValidator : AbstractValidator<CreateAlbumRequest>
{
public CreateAlbumRequestValidator()
{
RuleFor(x => x.Title)
.NotEmpty()
.MaximumLength(200);
RuleFor(x => x.Description)
.MaximumLength(256);
RuleFor(x => x.ReleaseYear)
.InclusiveBetween(AlbumReleaseYear.Earliest, AlbumReleaseYear.Latest)
.When(x => x.ReleaseYear.HasValue);
}
}
@@ -0,0 +1,21 @@
using FluentValidation;
using Musify.Api.DataTransferObjects.Albums;
namespace Musify.Api.Validators.Albums;
public sealed class UpdateAlbumRequestValidator : AbstractValidator<UpdateAlbumRequest>
{
public UpdateAlbumRequestValidator()
{
RuleFor(x => x.NewTitle)
.NotEmpty()
.MaximumLength(200);
RuleFor(x => x.NewDescription)
.MaximumLength(256);
RuleFor(x => x.NewReleaseYear)
.InclusiveBetween(AlbumReleaseYear.Earliest, AlbumReleaseYear.Latest)
.When(x => x.NewReleaseYear.HasValue);
}
}