-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Recep Güneş
committed
Aug 31, 2023
1 parent
406d97e
commit 7459fbb
Showing
13 changed files
with
164 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VUE_APP_TITLE=Url Shortener App | ||
VUE_APP_API_GATEWAY_URL=http://localhost:8083 | ||
VUE_APP_API_GATEWAY_URL=http://localhost:5043 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VUE_APP_TITLE=Url Shortener App | ||
VUE_APP_API_GATEWAY_URL=http://apigateway:80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:lts-alpine | ||
WORKDIR /app | ||
# install vite globally | ||
RUN npm install -g @vue/cli | ||
# copy all filtes | ||
COPY . . | ||
# install all deps | ||
RUN yarn install | ||
|
||
# vite default port | ||
EXPOSE 8080 | ||
CMD ["vue", "serve"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Shortener/Infrastructure/Commands/ReachUrlCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using MediatR; | ||
using Microsoft.EntityFrameworkCore; | ||
using Shortener.Infrastructure.Context; | ||
|
||
namespace Shortener.Infrastructure.Commands | ||
{ | ||
public class ReachUrlDto | ||
{ | ||
public string Message { get; set; } = string.Empty; | ||
} | ||
|
||
public class ReachUrlCommand : IRequest<ReachUrlDto> | ||
{ | ||
public string ShortPath { get; set; } | ||
public ReachUrlCommand(string shortPath) | ||
{ | ||
ShortPath = shortPath; | ||
} | ||
} | ||
|
||
public class ReachUrlCommandHandler : IRequestHandler<ReachUrlCommand, ReachUrlDto> | ||
{ | ||
private readonly AppDbContext dbContext; | ||
public ReachUrlCommandHandler(AppDbContext _dbContext) | ||
{ | ||
dbContext = _dbContext; | ||
} | ||
public async Task<ReachUrlDto> Handle(ReachUrlCommand request, CancellationToken cancellationToken) | ||
{ | ||
var url = await dbContext.Urls.FirstOrDefaultAsync(p => p.ShortPath == request.ShortPath); | ||
if (url == null) | ||
{ | ||
return new() { Message = "an error occurred" }; | ||
} | ||
url.RequestCounter++; | ||
url.LastRequestedDate = DateTime.UtcNow; | ||
await dbContext.SaveChangesAsync(); | ||
return new() { Message = "it is okay" }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
global using Xunit; | ||
global using Microsoft.Extensions.Logging; | ||
global using Moq; | ||
global using Moq; | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters