Skip to content

Commit

Permalink
Refactor Constants, Make all of them internal static.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadKarimi committed Jan 9, 2024
1 parent c3d3f5e commit 17a0eff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentValidation;
using SwiftLink.Application.Resources;

namespace SwiftLink.Application.UseCases.Links.GenerateCommand;

Expand All @@ -8,6 +7,6 @@ public class GenerateShortCodeValidator : AbstractValidator<GenerateShortCodeCom
public GenerateShortCodeValidator()
{
RuleFor(x => x.Url).NotNull()
.WithMessage(ApplicationMessage.Link.UrlMustBeSent);
.WithMessage(Constants.Link.UrlMustBeSent);
}
}
4 changes: 3 additions & 1 deletion src/SwiftLink.Presentation/Constants/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace SwiftLink.Presentation;

internal static class Constants
internal static class Constants
{
public const string UnHandledExceptions = "oops! something went wrong :(";

public static class EndPointFilterMessages
{
public const string InvalidUrl = "Url is not valid! :(";
Expand Down
6 changes: 3 additions & 3 deletions src/SwiftLink.Presentation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using Microsoft.AspNetCore.Diagnostics;
using SwiftLink.Application;
using SwiftLink.Infrastructure;
using SwiftLink.Presentation;
using SwiftLink.Shared;
using SwiftLink.Shared.Constants;

var builder = WebApplication.CreateBuilder(args);
{
Expand Down Expand Up @@ -42,12 +42,12 @@
context.Response.ContentType = "application/json";
var exceptionHandlerPathFeature = context.Features.Get<IExceptionHandlerPathFeature>();
var exception = exceptionHandlerPathFeature?.Error;
await context.Response.WriteAsync(Result.Failure(Error.DefaultMessage).ToString()!);
await context.Response.WriteAsync(Result.Failure(Constants.UnHandledExceptions).ToString()!);
});
});

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
5 changes: 0 additions & 5 deletions src/SwiftLink.Shared/Constants/Constants.cs

This file was deleted.

0 comments on commit 17a0eff

Please sign in to comment.