mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(services): ✨🚧 scaffold SharedKernel.Apis
This commit is contained in:
parent
941d077ece
commit
f4885a4f60
28 changed files with 244 additions and 114 deletions
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
|
|
@ -1,5 +1,17 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: nuget
|
||||
directory: "/services/SharedKernel/FilterLists.SharedKernel.Apis.Clients"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "11:00"
|
||||
open-pull-requests-limit: 99
|
||||
- package-ecosystem: nuget
|
||||
directory: "/services/SharedKernel/FilterLists.SharedKernel.Apis.Contracts"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "11:00"
|
||||
open-pull-requests-limit: 99
|
||||
- package-ecosystem: nuget
|
||||
directory: "/services/SharedKernel/FilterLists.SharedKernel.Logging"
|
||||
schedule:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
|
|||
|
||||
# restore API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/FilterLists.SharedKernel.Apis.Contracts.csproj SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Clients/FilterLists.SharedKernel.Apis.Clients.csproj SharedKernel/FilterLists.SharedKernel.Apis.Clients/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Archival/FilterLists.Archival.Infrastructure/FilterLists.Archival.Infrastructure.csproj Archival/FilterLists.Archival.Infrastructure/
|
||||
COPY Archival/FilterLists.Archival.Application/FilterLists.Archival.Application.csproj Archival/FilterLists.Archival.Application/
|
||||
|
|
@ -18,6 +20,8 @@ RUN dotnet restore
|
|||
|
||||
# build API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/. SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Clients/. SharedKernel/FilterLists.SharedKernel.Apis.Clients/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/. SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Archival/FilterLists.Archival.Infrastructure/. Archival/FilterLists.Archival.Infrastructure/
|
||||
COPY Archival/FilterLists.Archival.Application/. Archival/FilterLists.Archival.Application/
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
|
|||
|
||||
# restore API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/FilterLists.SharedKernel.Apis.Contracts.csproj SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Clients/FilterLists.SharedKernel.Apis.Clients.csproj SharedKernel/FilterLists.SharedKernel.Apis.Clients/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Archival/FilterLists.Archival.Infrastructure/FilterLists.Archival.Infrastructure.csproj Archival/FilterLists.Archival.Infrastructure/
|
||||
COPY Archival/FilterLists.Archival.Application/FilterLists.Archival.Application.csproj Archival/FilterLists.Archival.Application/
|
||||
|
|
@ -17,6 +19,8 @@ RUN dotnet restore
|
|||
|
||||
# build API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/. SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Clients/. SharedKernel/FilterLists.SharedKernel.Apis.Clients/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/. SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Archival/FilterLists.Archival.Infrastructure/. Archival/FilterLists.Archival.Infrastructure/
|
||||
COPY Archival/FilterLists.Archival.Application/. Archival/FilterLists.Archival.Application/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using FilterLists.Archival.Infrastructure.Persistence;
|
||||
using FilterLists.Archival.Infrastructure.Scheduling;
|
||||
using FilterLists.SharedKernel.Apis.Clients;
|
||||
using FilterLists.SharedKernel.Logging;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -21,8 +22,9 @@ public static void AddInfrastructureServices(this IServiceCollection services, I
|
|||
_ = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
||||
|
||||
services.AddSharedKernelLogging();
|
||||
services.AddPersistenceServices(configuration);
|
||||
services.AddSchedulingServices(configuration);
|
||||
services.AddApiClients();
|
||||
services.AddPersistenceServices(configuration);
|
||||
}
|
||||
|
||||
public static void UseInfrastructure(this IApplicationBuilder app)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\SharedKernel\FilterLists.SharedKernel.Apis.Clients\FilterLists.SharedKernel.Apis.Clients.csproj" />
|
||||
<ProjectReference Include="..\..\SharedKernel\FilterLists.SharedKernel.Logging\FilterLists.SharedKernel.Logging.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public LanguagesController(IMediator mediator)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetLanguages.LanguageViewModel>), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetLanguages.LanguageVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetLanguages.Query(), cancellationToken));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public LicensesController(IMediator mediator)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetLicenses.LicenseViewModel>), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetLicenses.LicenseVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetLicenses.Query(), cancellationToken));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Directory.Application.Queries;
|
||||
using FilterLists.SharedKernel.Apis.Contracts.Directory;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
|
@ -20,14 +21,14 @@ public ListsController(IMediator mediator)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetLists.ListViewModel>), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetLists.ListVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetLists.Query(), cancellationToken));
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType(typeof(GetListDetails.ListViewModel), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(ListDetailsVm), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetDetails(int id, CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetListDetails.Query(id), cancellationToken));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public MaintainersController(IMediator mediator)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetMaintainers.MaintainerViewModel>), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetMaintainers.MaintainerVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetMaintainers.Query(), cancellationToken));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public SoftwareController(IMediator mediator)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetSoftware.SoftwareViewModel>), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetSoftware.SoftwareVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetSoftware.Query(), cancellationToken));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public SyntaxesController(IMediator mediator)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetSyntaxes.SyntaxViewModel>), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetSyntaxes.SyntaxVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetSyntaxes.Query(), cancellationToken));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public TagsController(IMediator mediator)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetTags.TagViewModel>), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(IEnumerable<GetTags.TagVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await _mediator.Send(new GetTags.Query(), cancellationToken));
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
|
|||
|
||||
# restore API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/FilterLists.SharedKernel.Apis.Contracts.csproj SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Directory/FilterLists.Directory.Domain/FilterLists.Directory.Domain.csproj Directory/FilterLists.Directory.Domain/
|
||||
COPY Directory/FilterLists.Directory.Infrastructure/FilterLists.Directory.Infrastructure.csproj Directory/FilterLists.Directory.Infrastructure/
|
||||
|
|
@ -21,6 +22,7 @@ RUN dotnet restore
|
|||
|
||||
# build API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/. SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/. SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Directory/FilterLists.Directory.Domain/. Directory/FilterLists.Directory.Domain/
|
||||
COPY Directory/FilterLists.Directory.Infrastructure/. Directory/FilterLists.Directory.Infrastructure/
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
|
|||
|
||||
# restore API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/FilterLists.SharedKernel.Apis.Contracts.csproj SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Directory/FilterLists.Directory.Domain/FilterLists.Directory.Domain.csproj Directory/FilterLists.Directory.Domain/
|
||||
COPY Directory/FilterLists.Directory.Infrastructure/FilterLists.Directory.Infrastructure.csproj Directory/FilterLists.Directory.Infrastructure/
|
||||
|
|
@ -20,6 +21,7 @@ RUN dotnet restore
|
|||
|
||||
# build API
|
||||
WORKDIR /app
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Apis.Contracts/. SharedKernel/FilterLists.SharedKernel.Apis.Contracts/
|
||||
COPY SharedKernel/FilterLists.SharedKernel.Logging/. SharedKernel/FilterLists.SharedKernel.Logging/
|
||||
COPY Directory/FilterLists.Directory.Domain/. Directory/FilterLists.Directory.Domain/
|
||||
COPY Directory/FilterLists.Directory.Infrastructure/. Directory/FilterLists.Directory.Infrastructure/
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetLanguages
|
||||
{
|
||||
public class Query : IRequest<IEnumerable<LanguageViewModel>>
|
||||
public class Query : IRequest<IEnumerable<LanguageVm>>
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<LanguageViewModel>>
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<LanguageVm>>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -28,30 +28,30 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<LanguageViewModel>> Handle(
|
||||
public async Task<IEnumerable<LanguageVm>> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Languages
|
||||
.Where(l => l.FilterListLanguages.Any())
|
||||
.OrderBy(l => l.Iso6391)
|
||||
.ProjectTo<LanguageViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<LanguageVm>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class LicenseViewModelProfile : Profile
|
||||
public class LanguageVmProfile : Profile
|
||||
{
|
||||
public LicenseViewModelProfile()
|
||||
public LanguageVmProfile()
|
||||
{
|
||||
CreateMap<Language, LanguageViewModel>()
|
||||
CreateMap<Language, LanguageVm>()
|
||||
.ForMember(l => l.FilterListIds,
|
||||
o => o.MapFrom(l =>
|
||||
l.FilterListLanguages.Select(fll => fll.FilterListId).OrderBy(flid => flid)));
|
||||
}
|
||||
}
|
||||
|
||||
public class LanguageViewModel
|
||||
public class LanguageVm
|
||||
{
|
||||
public string Iso6391 { get; private set; } = null!;
|
||||
public string Name { get; private set; } = null!;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetLicenses
|
||||
{
|
||||
public class Query : IRequest<IEnumerable<LicenseViewModel>>
|
||||
public class Query : IRequest<IEnumerable<LicenseVm>>
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<LicenseViewModel>>
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<LicenseVm>>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -29,29 +29,29 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<LicenseViewModel>> Handle(
|
||||
public async Task<IEnumerable<LicenseVm>> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Licenses
|
||||
.OrderBy(l => l.Id)
|
||||
.ProjectTo<LicenseViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<LicenseVm>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class LicenseViewModelProfile : Profile
|
||||
public class LicenseVmProfile : Profile
|
||||
{
|
||||
public LicenseViewModelProfile()
|
||||
public LicenseVmProfile()
|
||||
{
|
||||
CreateMap<License, LicenseViewModel>()
|
||||
CreateMap<License, LicenseVm>()
|
||||
.ForMember(l => l.FilterListIds,
|
||||
o => o.MapFrom(l =>
|
||||
l.FilterLists.Select(fl => fl.Id).OrderBy(flid => flid)));
|
||||
}
|
||||
}
|
||||
|
||||
public class LicenseViewModel
|
||||
public class LicenseVm
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Context;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using FilterLists.SharedKernel.Apis.Contracts.Directory;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
|
@ -14,7 +13,7 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetListDetails
|
||||
{
|
||||
public class Query : IRequest<ListViewModel>
|
||||
public class Query : IRequest<ListDetailsVm>
|
||||
{
|
||||
public Query(int id)
|
||||
{
|
||||
|
|
@ -24,7 +23,7 @@ public Query(int id)
|
|||
public int Id { get; }
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, ListViewModel>
|
||||
public class Handler : IRequestHandler<Query, ListDetailsVm>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -35,21 +34,21 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<ListViewModel> Handle(
|
||||
public async Task<ListDetailsVm> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.FilterLists
|
||||
.ProjectTo<ListViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<ListDetailsVm>(_mapper.ConfigurationProvider)
|
||||
.SingleOrDefaultAsync(fl => fl.Id == request.Id, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class ListViewModelProfile : Profile
|
||||
public class ListDetailsVmProfile : Profile
|
||||
{
|
||||
public ListViewModelProfile()
|
||||
public ListDetailsVmProfile()
|
||||
{
|
||||
CreateMap<FilterList, ListViewModel>()
|
||||
CreateMap<FilterList, ListDetailsVm>()
|
||||
.ForMember(fl => fl.SyntaxIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListSyntaxes.Select(fls => fls.SyntaxId).OrderBy(sid => sid)))
|
||||
|
|
@ -86,47 +85,12 @@ public ListViewModelProfile()
|
|||
}
|
||||
}
|
||||
|
||||
public class ViewUrlViewModelProfile : Profile
|
||||
public class ListDetailsViewUrlVmProfile : Profile
|
||||
{
|
||||
public ViewUrlViewModelProfile()
|
||||
public ListDetailsViewUrlVmProfile()
|
||||
{
|
||||
CreateMap<FilterListViewUrl, ViewUrlViewModel>();
|
||||
CreateMap<FilterListViewUrl, ListDetailsViewUrlVm>();
|
||||
}
|
||||
}
|
||||
|
||||
public class ListViewModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string? Description { get; private set; }
|
||||
public int? LicenseId { get; private set; }
|
||||
public IEnumerable<int>? SyntaxIds { get; private set; }
|
||||
public IEnumerable<string>? Iso6391s { get; private set; }
|
||||
public IEnumerable<int>? TagIds { get; private set; }
|
||||
public IEnumerable<ViewUrlViewModel>? ViewUrls { get; private set; }
|
||||
public Uri? HomeUrl { get; private set; }
|
||||
public Uri? OnionUrl { get; private set; }
|
||||
public Uri? PolicyUrl { get; private set; }
|
||||
public Uri? SubmissionUrl { get; private set; }
|
||||
public Uri? IssuesUrl { get; private set; }
|
||||
public Uri? ForumUrl { get; private set; }
|
||||
public Uri? ChatUrl { get; private set; }
|
||||
public string? EmailAddress { get; private set; }
|
||||
public Uri? DonateUrl { get; private set; }
|
||||
public IEnumerable<int>? MaintainerIds { get; private set; }
|
||||
public IEnumerable<int>? UpstreamFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? ForkFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? IncludedInFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? IncludesFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? DependencyFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? DependentFilterListIds { get; private set; }
|
||||
}
|
||||
|
||||
public class ViewUrlViewModel
|
||||
{
|
||||
public short SegmentNumber { get; private set; }
|
||||
public short Primariness { get; private set; }
|
||||
public Uri Url { get; private set; } = null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,11 +13,11 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetLists
|
||||
{
|
||||
public class Query : IRequest<IEnumerable<ListViewModel>>
|
||||
public class Query : IRequest<IEnumerable<ListVm>>
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<ListViewModel>>
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<ListVm>>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -28,22 +28,22 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ListViewModel>> Handle(
|
||||
public async Task<IEnumerable<ListVm>> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.FilterLists
|
||||
.OrderBy(fl => fl.Id)
|
||||
.ProjectTo<ListViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<ListVm>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class ListViewModelProfile : Profile
|
||||
public class ListVmProfile : Profile
|
||||
{
|
||||
public ListViewModelProfile()
|
||||
public ListVmProfile()
|
||||
{
|
||||
CreateMap<FilterList, ListViewModel>()
|
||||
CreateMap<FilterList, ListVm>()
|
||||
.ForMember(fl => fl.SyntaxIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListSyntaxes.Select(fls => fls.SyntaxId).OrderBy(sid => sid)))
|
||||
|
|
@ -59,7 +59,7 @@ public ListViewModelProfile()
|
|||
}
|
||||
}
|
||||
|
||||
public class ListViewModel
|
||||
public class ListVm
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetMaintainers
|
||||
{
|
||||
public class Query : IRequest<IEnumerable<MaintainerViewModel>>
|
||||
public class Query : IRequest<IEnumerable<MaintainerVm>>
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<MaintainerViewModel>>
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<MaintainerVm>>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -29,29 +29,29 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<MaintainerViewModel>> Handle(
|
||||
public async Task<IEnumerable<MaintainerVm>> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Maintainers
|
||||
.OrderBy(m => m.Id)
|
||||
.ProjectTo<MaintainerViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<MaintainerVm>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class MaintainerViewModelProfile : Profile
|
||||
public class MaintainerVmProfile : Profile
|
||||
{
|
||||
public MaintainerViewModelProfile()
|
||||
public MaintainerVmProfile()
|
||||
{
|
||||
CreateMap<Maintainer, MaintainerViewModel>()
|
||||
CreateMap<Maintainer, MaintainerVm>()
|
||||
.ForMember(m => m.FilterListIds,
|
||||
o => o.MapFrom(m =>
|
||||
m.FilterListMaintainers.Select(flm => flm.FilterListId).OrderBy(flid => flid)));
|
||||
}
|
||||
}
|
||||
|
||||
public class MaintainerViewModel
|
||||
public class MaintainerVm
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetSoftware
|
||||
{
|
||||
public class Query : IRequest<IEnumerable<SoftwareViewModel>>
|
||||
public class Query : IRequest<IEnumerable<SoftwareVm>>
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<SoftwareViewModel>>
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<SoftwareVm>>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -29,29 +29,29 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SoftwareViewModel>> Handle(
|
||||
public async Task<IEnumerable<SoftwareVm>> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Software
|
||||
.OrderBy(s => s.Id)
|
||||
.ProjectTo<SoftwareViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<SoftwareVm>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class SoftwareViewModelProfile : Profile
|
||||
public class SoftwareVmProfile : Profile
|
||||
{
|
||||
public SoftwareViewModelProfile()
|
||||
public SoftwareVmProfile()
|
||||
{
|
||||
CreateMap<Software, SoftwareViewModel>()
|
||||
CreateMap<Software, SoftwareVm>()
|
||||
.ForMember(s => s.SyntaxIds,
|
||||
o => o.MapFrom(s =>
|
||||
s.SoftwareSyntaxes.Select(ss => ss.SyntaxId).OrderBy(sid => sid)));
|
||||
}
|
||||
}
|
||||
|
||||
public class SoftwareViewModel
|
||||
public class SoftwareVm
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetSyntaxes
|
||||
{
|
||||
public class Query : IRequest<IEnumerable<SyntaxViewModel>>
|
||||
public class Query : IRequest<IEnumerable<SyntaxVm>>
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<SyntaxViewModel>>
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<SyntaxVm>>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -29,22 +29,22 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SyntaxViewModel>> Handle(
|
||||
public async Task<IEnumerable<SyntaxVm>> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Syntaxes
|
||||
.OrderBy(s => s.Id)
|
||||
.ProjectTo<SyntaxViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<SyntaxVm>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class SyntaxViewModelProfile : Profile
|
||||
public class SyntaxVmProfile : Profile
|
||||
{
|
||||
public SyntaxViewModelProfile()
|
||||
public SyntaxVmProfile()
|
||||
{
|
||||
CreateMap<Syntax, SyntaxViewModel>()
|
||||
CreateMap<Syntax, SyntaxVm>()
|
||||
.ForMember(s => s.FilterListIds,
|
||||
o => o.MapFrom(s =>
|
||||
s.FilterListSyntaxes.Select(sls => sls.FilterListId).OrderBy(flid => flid)))
|
||||
|
|
@ -54,7 +54,7 @@ public SyntaxViewModelProfile()
|
|||
}
|
||||
}
|
||||
|
||||
public class SyntaxViewModel
|
||||
public class SyntaxVm
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ namespace FilterLists.Directory.Application.Queries
|
|||
{
|
||||
public static class GetTags
|
||||
{
|
||||
public class Query : IRequest<IEnumerable<TagViewModel>>
|
||||
public class Query : IRequest<IEnumerable<TagVm>>
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<TagViewModel>>
|
||||
public class Handler : IRequestHandler<Query, IEnumerable<TagVm>>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
|
@ -28,29 +28,29 @@ public Handler(IQueryContext context, IMapper mapper)
|
|||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TagViewModel>> Handle(
|
||||
public async Task<IEnumerable<TagVm>> Handle(
|
||||
Query request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Tags
|
||||
.OrderBy(t => t.Id)
|
||||
.ProjectTo<TagViewModel>(_mapper.ConfigurationProvider)
|
||||
.ProjectTo<TagVm>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class TagViewModelProfile : Profile
|
||||
public class TagVmProfile : Profile
|
||||
{
|
||||
public TagViewModelProfile()
|
||||
public TagVmProfile()
|
||||
{
|
||||
CreateMap<Tag, TagViewModel>()
|
||||
CreateMap<Tag, TagVm>()
|
||||
.ForMember(t => t.FilterListIds,
|
||||
o => o.MapFrom(t =>
|
||||
t.FilterListTags.Select(flt => flt.FilterListId).OrderBy(flid => flid)));
|
||||
}
|
||||
}
|
||||
|
||||
public class TagViewModel
|
||||
public class TagVm
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\SharedKernel\FilterLists.SharedKernel.Apis.Contracts\FilterLists.SharedKernel.Apis.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\SharedKernel\FilterLists.SharedKernel.Logging\FilterLists.SharedKernel.Logging.csproj" />
|
||||
<ProjectReference Include="..\FilterLists.Directory.Domain\FilterLists.Directory.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.Archival.Infras
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedKernel", "SharedKernel", "{59197818-6C72-4A3C-A595-49F3D7D2EB18}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilterLists.SharedKernel.Logging", "SharedKernel\FilterLists.SharedKernel.Logging\FilterLists.SharedKernel.Logging.csproj", "{5485F55E-DFED-4DA0-8A00-220B081FAC96}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.SharedKernel.Logging", "SharedKernel\FilterLists.SharedKernel.Logging\FilterLists.SharedKernel.Logging.csproj", "{5485F55E-DFED-4DA0-8A00-220B081FAC96}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilterLists.SharedKernel.Apis.Contracts", "SharedKernel\FilterLists.SharedKernel.Apis.Contracts\FilterLists.SharedKernel.Apis.Contracts.csproj", "{D8B65709-B68E-42D6-8500-68EE309177D5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterLists.SharedKernel.Apis.Clients", "SharedKernel\FilterLists.SharedKernel.Apis.Clients\FilterLists.SharedKernel.Apis.Clients.csproj", "{FF6F3D83-A96C-412C-BAFF-63BA89ADD31F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -112,6 +116,14 @@ Global
|
|||
{5485F55E-DFED-4DA0-8A00-220B081FAC96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5485F55E-DFED-4DA0-8A00-220B081FAC96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5485F55E-DFED-4DA0-8A00-220B081FAC96}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D8B65709-B68E-42D6-8500-68EE309177D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D8B65709-B68E-42D6-8500-68EE309177D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8B65709-B68E-42D6-8500-68EE309177D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8B65709-B68E-42D6-8500-68EE309177D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FF6F3D83-A96C-412C-BAFF-63BA89ADD31F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FF6F3D83-A96C-412C-BAFF-63BA89ADD31F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FF6F3D83-A96C-412C-BAFF-63BA89ADD31F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FF6F3D83-A96C-412C-BAFF-63BA89ADD31F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -128,6 +140,8 @@ Global
|
|||
{11669839-E666-477B-A1B6-276041AD3768} = {5E52FEF9-9605-4ACB-8A42-A20E06331599}
|
||||
{A0B77015-E8C4-41D3-B63D-BF818026298C} = {5E52FEF9-9605-4ACB-8A42-A20E06331599}
|
||||
{5485F55E-DFED-4DA0-8A00-220B081FAC96} = {59197818-6C72-4A3C-A595-49F3D7D2EB18}
|
||||
{D8B65709-B68E-42D6-8500-68EE309177D5} = {59197818-6C72-4A3C-A595-49F3D7D2EB18}
|
||||
{FF6F3D83-A96C-412C-BAFF-63BA89ADD31F} = {59197818-6C72-4A3C-A595-49F3D7D2EB18}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {758B57EF-7505-4BE2-90A2-E2DE2EC32909}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using RestSharp;
|
||||
|
||||
namespace FilterLists.SharedKernel.Apis.Clients
|
||||
{
|
||||
public static class ConfigurationExtensions
|
||||
{
|
||||
public static void AddApiClients(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IRestClient, RestClient>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Authors>Collin M. Barrett</Authors>
|
||||
<Company>FilterLists</Company>
|
||||
<Product>FilterLists Shared Kernel API Clients</Product>
|
||||
<Description>The independent, comprehensive directory of filter and host lists for advertisements, trackers, malware, and annoyances.</Description>
|
||||
<Copyright>Copyright (c) 2020 Collin M. Barrett</Copyright>
|
||||
<RepositoryUrl>https://github.com/collinbarrett/FilterLists</RepositoryUrl>
|
||||
<PackageProjectUrl>https://filterlists.com</PackageProjectUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702;CA2007</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<NoWarn>CA2007</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.8" />
|
||||
<PackageReference Include="RestSharp" Version="106.11.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FilterLists.SharedKernel.Apis.Contracts\FilterLists.SharedKernel.Apis.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FilterLists.SharedKernel.Apis.Contracts.Directory
|
||||
{
|
||||
public class ListDetailsVm
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = null!;
|
||||
public string? Description { get; private set; }
|
||||
public int? LicenseId { get; private set; }
|
||||
public IEnumerable<int>? SyntaxIds { get; private set; }
|
||||
public IEnumerable<string>? Iso6391s { get; private set; }
|
||||
public IEnumerable<int>? TagIds { get; private set; }
|
||||
public IEnumerable<ListDetailsViewUrlVm>? ViewUrls { get; private set; }
|
||||
public Uri? HomeUrl { get; private set; }
|
||||
public Uri? OnionUrl { get; private set; }
|
||||
public Uri? PolicyUrl { get; private set; }
|
||||
public Uri? SubmissionUrl { get; private set; }
|
||||
public Uri? IssuesUrl { get; private set; }
|
||||
public Uri? ForumUrl { get; private set; }
|
||||
public Uri? ChatUrl { get; private set; }
|
||||
public string? EmailAddress { get; private set; }
|
||||
public Uri? DonateUrl { get; private set; }
|
||||
public IEnumerable<int>? MaintainerIds { get; private set; }
|
||||
public IEnumerable<int>? UpstreamFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? ForkFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? IncludedInFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? IncludesFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? DependencyFilterListIds { get; private set; }
|
||||
public IEnumerable<int>? DependentFilterListIds { get; private set; }
|
||||
}
|
||||
|
||||
public class ListDetailsViewUrlVm
|
||||
{
|
||||
public short SegmentNumber { get; private set; }
|
||||
public short Primariness { get; private set; }
|
||||
public Uri Url { get; private set; } = null!;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Authors>Collin M. Barrett</Authors>
|
||||
<Company>FilterLists</Company>
|
||||
<Product>FilterLists Shared Kernel API Contracts</Product>
|
||||
<Description>The independent, comprehensive directory of filter and host lists for advertisements, trackers, malware, and annoyances.</Description>
|
||||
<Copyright>Copyright (c) 2020 Collin M. Barrett</Copyright>
|
||||
<RepositoryUrl>https://github.com/collinbarrett/FilterLists</RepositoryUrl>
|
||||
<PackageProjectUrl>https://filterlists.com</PackageProjectUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in a new issue