Created Woodpecker CI/CD deployment
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Created Dockerfile for packing up API and Web projects as Docker image
This commit is contained in:
10
API/YABA.API/Settings/Auth0Settings.cs
Normal file
10
API/YABA.API/Settings/Auth0Settings.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace YABA.API.Settings
|
||||
{
|
||||
public class Auth0Settings
|
||||
{
|
||||
public string Domain { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
public string ClientId { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
}
|
||||
}
|
||||
26
API/YABA.API/Settings/AutoMapperProfile.cs
Normal file
26
API/YABA.API/Settings/AutoMapperProfile.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using AutoMapper;
|
||||
using System.Net;
|
||||
using YABA.API.ViewModels;
|
||||
using YABA.API.ViewModels.Bookmarks;
|
||||
using YABA.API.ViewModels.Tags;
|
||||
using YABA.Common.DTOs;
|
||||
using YABA.Common.DTOs.Bookmarks;
|
||||
using YABA.Common.DTOs.Tags;
|
||||
|
||||
namespace YABA.API.Settings
|
||||
{
|
||||
public class AutoMapperProfile : Profile
|
||||
{
|
||||
public AutoMapperProfile()
|
||||
{
|
||||
CreateMap<UserDTO, UserResponse>();
|
||||
CreateMap<BookmarkDTO, BookmarkResponse>()
|
||||
.ForMember(dest => dest.Title, opt => opt.MapFrom(src => WebUtility.HtmlDecode(src.Title)))
|
||||
.ForMember(dest => dest.Description, opt => opt.MapFrom(src => WebUtility.HtmlDecode(src.Description)));
|
||||
CreateMap<WebsiteMetaDataDTO, GetWebsiteMetaDataResponse>();
|
||||
CreateMap<BookmarkDTO, PatchBookmarkRequest>();
|
||||
CreateMap<PatchBookmarkRequest, UpdateBookmarkRequestDTO>();
|
||||
CreateMap<TagDTO, TagResponse>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
34
API/YABA.API/Settings/DevOnlyAttribute.cs
Normal file
34
API/YABA.API/Settings/DevOnlyAttribute.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
namespace YABA.API.Settings
|
||||
{
|
||||
// Source: https://stackoverflow.com/questions/56495475/asp-net-core-its-possible-to-configure-an-action-in-controller-only-in-developm
|
||||
public class DevOnlyAttribute : Attribute, IFilterFactory
|
||||
{
|
||||
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
|
||||
{
|
||||
return new DevOnlyAttributeImpl(serviceProvider.GetRequiredService<IWebHostEnvironment>());
|
||||
}
|
||||
|
||||
public bool IsReusable => true;
|
||||
|
||||
private class DevOnlyAttributeImpl : Attribute, IAuthorizationFilter
|
||||
{
|
||||
public DevOnlyAttributeImpl(IWebHostEnvironment hostingEnv)
|
||||
{
|
||||
HostingEnv = hostingEnv;
|
||||
}
|
||||
|
||||
private IWebHostEnvironment HostingEnv { get; }
|
||||
|
||||
public void OnAuthorization(AuthorizationFilterContext context)
|
||||
{
|
||||
if (!HostingEnv.IsDevelopment())
|
||||
{
|
||||
context.Result = new NotFoundResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace YABA.API.Settings.Swashbuckle
|
||||
{
|
||||
public class RemoveVersionParameterFilter : IOperationFilter
|
||||
{
|
||||
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||
{
|
||||
var versionParameter = operation.Parameters.Single(p => p.Name == "version");
|
||||
operation.Parameters.Remove(versionParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace YABA.API.Settings.Swashbuckle
|
||||
{
|
||||
public class ReplaceVersionWithExactValueInPathFilter : IDocumentFilter
|
||||
{
|
||||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
||||
{
|
||||
var paths = new OpenApiPaths();
|
||||
foreach (var path in swaggerDoc.Paths)
|
||||
{
|
||||
paths.Add(path.Key.Replace("v{version}", swaggerDoc.Info.Version), path.Value);
|
||||
}
|
||||
swaggerDoc.Paths = paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user