Skip to content

Commit

Permalink
Merge pull request #49 from kentprince13/Generatelink-implementation
Browse files Browse the repository at this point in the history
Generatelink implementation
  • Loading branch information
thisisnabi authored Sep 20, 2024
2 parents 1faf821 + 0317459 commit 1f9e334
Show file tree
Hide file tree
Showing 50 changed files with 131 additions and 150 deletions.
4 changes: 1 addition & 3 deletions src/Blogger.APIs/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace Blogger.APIs;
namespace Blogger.APIs;

public static class DependencyInjection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Articles.CreateArticle;

namespace Blogger.APIs.Endpoints.Articles.CreateArticle;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Blogger.Application.Articles.CreateArticle;
using Blogger.Domain.ArticleAggregate;
using System.Collections.Immutable;

namespace Blogger.APIs.Endpoints.Articles.CreateArticle;
namespace Blogger.APIs.Endpoints.Articles.CreateArticle;

public class CreateArticleMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Blogger.Domain.ArticleAggregate;
namespace Blogger.APIs.Endpoints.Articles.CreateArticle;
namespace Blogger.APIs.Endpoints.Articles.CreateArticle;

public record CreateArticleResponse(string ArticleId);
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetArchive;

namespace Blogger.APIs.Endpoints.Articles.GetArchive;
namespace Blogger.APIs.Endpoints.Articles.GetArchive;

public class GetArchiveEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetArchive;

namespace Blogger.APIs.Endpoints.Articles.GetArchive;
namespace Blogger.APIs.Endpoints.Articles.GetArchive;

public class GetArchiveMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Articles.GetArticle;
using Blogger.Domain.ArticleAggregate;

namespace Blogger.APIs.Endpoints.Articles.GetArticle;
namespace Blogger.APIs.Endpoints.Articles.GetArticle;

public class GetArticleMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetArticles;

namespace Blogger.APIs.Endpoints.Articles.GetArticles;
namespace Blogger.APIs.Endpoints.Articles.GetArticles;

public class GetArticlesEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetArticles;

namespace Blogger.APIs.Endpoints.Articles.GetArticles;
namespace Blogger.APIs.Endpoints.Articles.GetArticles;

public class GetArticlesMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetPopularArticles;

namespace Blogger.APIs.Endpoints.Articles.GetPopularArticles;
namespace Blogger.APIs.Endpoints.Articles.GetPopularArticles;

public class GetPopularArticlesEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetPopularArticles;

namespace Blogger.APIs.Endpoints.Articles.GetPopularArticles;
namespace Blogger.APIs.Endpoints.Articles.GetPopularArticles;

public class GetPopularArticlesMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetPopularTags;

namespace Blogger.APIs.Endpoints.Articles.GetPopularTags;
namespace Blogger.APIs.Endpoints.Articles.GetPopularTags;

public class GetPopularTagsEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetPopularTags;

namespace Blogger.APIs.Endpoints.Articles.GetPopularTags;
namespace Blogger.APIs.Endpoints.Articles.GetPopularTags;

public class GetPopularTagsMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Articles.GetTaggedArticles;

namespace Blogger.APIs.Endpoints.Articles.GetTaggedArticles;
namespace Blogger.APIs.Endpoints.Articles.GetTaggedArticles;

public class GetTaggedArticlesEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Articles.GetTaggedArticles;
using Blogger.Domain.ArticleAggregate;

namespace Blogger.APIs.Endpoints.Articles.GetTaggedArticles;
namespace Blogger.APIs.Endpoints.Articles.GetTaggedArticles;

public class GetTaggedArticlesMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetTags;

namespace Blogger.APIs.Endpoints.Articles.GetTags;
namespace Blogger.APIs.Endpoints.Articles.GetTags;

public class GetTagsEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Articles.GetTags;

namespace Blogger.APIs.Endpoints.Articles.GetTags;
namespace Blogger.APIs.Endpoints.Articles.GetTags;

public class GetTagsMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Articles.MakeDraft;

namespace Blogger.APIs.Endpoints.Articles.MakeDraft;
namespace Blogger.APIs.Endpoints.Articles.MakeDraft;

public class MakeCommentEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Articles.MakeDraft;
using Blogger.Domain.ArticleAggregate;

namespace Blogger.APIs.Endpoints.Articles.MakeDraft;
namespace Blogger.APIs.Endpoints.Articles.MakeDraft;

public class MakeDraftMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Articles.PublishDraft;

namespace Blogger.APIs.Endpoints.Articles.PublishDraft;
namespace Blogger.APIs.Endpoints.Articles.PublishDraft;

public class PublishDraftEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Articles.PublishDraft;
using Blogger.Domain.ArticleAggregate;

namespace Blogger.APIs.Endpoints.Articles.PublishDraft;
namespace Blogger.APIs.Endpoints.Articles.PublishDraft;

public class PublishDraftMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Articles.UpdateDraft;

namespace Blogger.APIs.Endpoints.Articles.UpdateDraft;
namespace Blogger.APIs.Endpoints.Articles.UpdateDraft;

public class UpdateDraftEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Articles.UpdateDraft;
using Blogger.Domain.ArticleAggregate;

namespace Blogger.APIs.Endpoints.Articles.UpdateDraft;
namespace Blogger.APIs.Endpoints.Articles.UpdateDraft;

public class UpdateDraftMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Comments.ApproveComment;

namespace Blogger.APIs.Endpoints.Comments.ApproveComment;
namespace Blogger.APIs.Endpoints.Comments.ApproveComment;

public class ApproveCommentEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Comments.ApproveComment;

namespace Blogger.APIs.Endpoints.Comments.ApproveComment;
namespace Blogger.APIs.Endpoints.Comments.ApproveComment;

public class ApproveCommentMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Comments.ApproveReply;

namespace Blogger.APIs.Endpoints.Comments.ApproveReply;
namespace Blogger.APIs.Endpoints.Comments.ApproveReply;

public class ApproveReplyEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Comments.ApproveReply;
using Blogger.Domain.CommentAggregate;

namespace Blogger.APIs.Endpoints.Comments.ApproveReply;
namespace Blogger.APIs.Endpoints.Comments.ApproveReply;

public class ApproveReplyMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Comments.GetComments;

namespace Blogger.APIs.Endpoints.Comments.GetComments;
namespace Blogger.APIs.Endpoints.Comments.GetComments;

public class GetCommentsEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Comments.GetComments;
using Blogger.Domain.ArticleAggregate;

namespace Blogger.APIs.Endpoints.Comments.GetComments;
namespace Blogger.APIs.Endpoints.Comments.GetComments;

public class GetCommentsMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Blogger.Application.Comments.GetReplies;

namespace Blogger.APIs.Endpoints.Comments.GetReplies;
namespace Blogger.APIs.Endpoints.Comments.GetReplies;

public class GetRepliesEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Blogger.Application.Comments.GetReplies;
using Blogger.Domain.ArticleAggregate;
using Blogger.Domain.CommentAggregate;

namespace Blogger.APIs.Endpoints.Comments.GetReplies;
namespace Blogger.APIs.Endpoints.Comments.GetReplies;

public class GetRepliesMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Comments.MakeComment;

namespace Blogger.APIs.Endpoints.Comments.MakeComment;
namespace Blogger.APIs.Endpoints.Comments.MakeComment;

public class MakeCommentEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Blogger.Application.Comments.MakeComment;
using Blogger.Domain.ArticleAggregate;
using Blogger.Domain.CommentAggregate;

namespace Blogger.APIs.Endpoints.Comments.MakeComment;
namespace Blogger.APIs.Endpoints.Comments.MakeComment;

public class MakeCommentMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Comments.ReplyToComment;

namespace Blogger.APIs.Endpoints.Comments.ReplyToCommet;
namespace Blogger.APIs.Endpoints.Comments.ReplyToCommet;

public class ReplyToCommentEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.Application.Comments.ReplyToComment;
using Blogger.Domain.CommentAggregate;

namespace Blogger.APIs.Endpoints.Comments.ReplyToCommet;
namespace Blogger.APIs.Endpoints.Comments.ReplyToCommet;

public class ReplyToCommentMappingProfile : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Blogger.APIs.Endpoints;
using Blogger.Application.Subscribers.Subscribe;

namespace Blogger.APIs.Endpoints.Subscribers.Subscribe;
namespace Blogger.APIs.Endpoints.Subscribers.Subscribe;

public class SubscribeEndpoint : IEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Blogger.Application.Subscribers.Subscribe;
using Blogger.Domain.SubscriberAggregate;
using Blogger.Domain.SubscriberAggregate;

namespace Blogger.APIs.Endpoints.Subscribers.Subscribe;

Expand Down
7 changes: 1 addition & 6 deletions src/Blogger.APIs/ErrorHandling/GlobalExceptionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Blogger.BuildingBlocks.Domain;


using Microsoft.AspNetCore.Diagnostics;

namespace Blogger.APIs.ErrorHandling;
namespace Blogger.APIs.ErrorHandling;

public sealed class GlobalExceptionHandler : IExceptionHandler
{
Expand Down
25 changes: 25 additions & 0 deletions src/Blogger.APIs/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,29 @@
global using Blogger.APIs.Filters;
global using Blogger.Infrastructure;
global using Blogger.APIs.Abstractions;
global using Blogger.APIs.ErrorHandling;
global using Blogger.Application.Articles.CreateArticle;
global using Blogger.Application.Articles.GetArchive;
global using Blogger.Application.Articles.GetArticle;
global using Blogger.Application.Articles.GetArticles;
global using Blogger.Application.Articles.GetPopularArticles;
global using Blogger.Application.Articles.GetPopularTags;
global using Blogger.Application.Articles.GetTaggedArticles;
global using Blogger.Application.Articles.GetTags;
global using Blogger.Application.Articles.MakeDraft;
global using Blogger.Application.Articles.PublishDraft;
global using Blogger.Application.Articles.UpdateDraft;
global using Blogger.Application.Comments.ApproveComment;
global using Blogger.Application.Comments.ApproveReply;
global using Blogger.Application.Comments.GetComments;
global using Blogger.Application.Comments.GetReplies;
global using Blogger.Application.Comments.MakeComment;
global using Blogger.Application.Comments.ReplyToComment;
global using Blogger.Application.Subscribers.Subscribe;
global using Blogger.BuildingBlocks.Domain;
global using Blogger.Domain.ArticleAggregate;
global using Blogger.Domain.CommentAggregate;

global using Microsoft.AspNetCore.Diagnostics;
global using Microsoft.Extensions.DependencyInjection.Extensions;

2 changes: 0 additions & 2 deletions src/Blogger.APIs/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Blogger.APIs.ErrorHandling;

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddEnvironmentVariables();
Expand Down
2 changes: 1 addition & 1 deletion src/Blogger.Application/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ public static class ApplicationSettings
{
public static class ApproveLink
{
public const int ExpairationOnHours = 10;
public const int ExpirationOnHours = 10;
public const string ConfirmEmailSubject = "Confirm Your Engagement - thisisnabi.dev";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<MakeCommentCommandResponse> Handle(MakeCommentCommand request,
}

var link = _linkGenerator.Generate();
var approveLink = ApproveLink.Create(link, DateTime.UtcNow.AddHours(ApplicationSettings.ApproveLink.ExpairationOnHours));
var approveLink = ApproveLink.Create(link, DateTime.UtcNow.AddHours(ApplicationSettings.ApproveLink.ExpirationOnHours));

var comment = Comment.Create(request.ArticleId, request.Client, request.Content, approveLink);
comment.RaiseMakeCommentEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public async Task<ReplyToCommentCommandResponse> Handle(ReplyToCommentCommand re
if (comment is null) throw new NotFoundCommentException();

var link = linkGenerator.Generate();
var approveLink = ApproveLink.Create(link, DateTime.UtcNow.AddHours(ApplicationSettings.ApproveLink.ExpairationOnHours));
var approveLink = ApproveLink.Create(link, DateTime.UtcNow.AddHours(ApplicationSettings.ApproveLink.ExpirationOnHours));

var Reply = comment.ReplyComment(request.Client, request.Content, approveLink);
await commentRepository.SaveChangesAsync(cancellationToken);
Expand Down
2 changes: 2 additions & 0 deletions src/Blogger.Infrastructure/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// built-int
global using Microsoft.EntityFrameworkCore;
global using System.Collections.Immutable;
global using System.Text;

global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;

Expand Down
Loading

0 comments on commit 1f9e334

Please sign in to comment.