Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: created structure project and user register and login #10

Merged
merged 64 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b57eed5
refact: improvements in the entire project structure and tests
migueloliveiradev Jul 29, 2024
7be7985
refact: improvements in auth and tests
migueloliveiradev Aug 11, 2024
643cac3
fix: adjusts in login helper in tests
migueloliveiradev Aug 11, 2024
8f96cf5
feat: update packages
migueloliveiradev Aug 15, 2024
f379a7d
feat: install and configure SonarAnalyzer.CSharp
migueloliveiradev Aug 16, 2024
94122e4
feat: remove package FluentValidation
migueloliveiradev Aug 16, 2024
4e394ec
feat: install and configure Meziantou.Analyzer
migueloliveiradev Aug 16, 2024
a4dd1b9
cleanup: remove usings not used
migueloliveiradev Aug 16, 2024
4da4239
feat: adjust in handlers and tests
migueloliveiradev Aug 18, 2024
1ebb921
cleanup: remove usings not used
migueloliveiradev Aug 18, 2024
fd5640d
feat: created permission authorization
migueloliveiradev Aug 18, 2024
99c4772
feat: created global exception handler
migueloliveiradev Aug 18, 2024
c51cd8c
tests: created tests to refresh token
migueloliveiradev Aug 18, 2024
2c49c5a
refact: change dotnet test reporter
migueloliveiradev Aug 18, 2024
67f2204
Merge remote-tracking branch 'origin/main' into i4
migueloliveiradev Aug 18, 2024
bbdba8f
feat: add setup docker in github workflow
migueloliveiradev Aug 18, 2024
8c0df08
fix: add check docker version github workflow
migueloliveiradev Aug 18, 2024
f5c7281
fix: change host docker tests containers
migueloliveiradev Aug 18, 2024
e409725
Merge branch 'i4' of https://github.com/migueloliveiradev/living into i4
migueloliveiradev Aug 18, 2024
5edae44
fix: remove one dotnet test workflow
migueloliveiradev Aug 19, 2024
19fae61
fix: adjusts postgres connection in tests containers
migueloliveiradev Aug 19, 2024
63ff189
Merge branch 'i4' of https://github.com/migueloliveiradev/living into i4
migueloliveiradev Aug 19, 2024
13867c5
fix: change min code coverage
migueloliveiradev Aug 19, 2024
f4d73ea
fix: adjusts results-path github workflow
migueloliveiradev Aug 19, 2024
9c71931
fix: change coverage-path github workflow
migueloliveiradev Aug 19, 2024
2e1a0b8
fix: change tests results coverage-type
migueloliveiradev Aug 19, 2024
88074bd
fix: remove coverage min workflow
migueloliveiradev Aug 19, 2024
172d44f
fix: remoge generated code in tests code coverage
migueloliveiradev Aug 19, 2024
1e67bc7
fix: remove extension .g.cs code coverage
migueloliveiradev Aug 19, 2024
a24cec6
fix: change type DateTime to DateTimeOffSet to LockoutEnd in migration
migueloliveiradev Aug 22, 2024
681712c
feat: new validations in refresh token
migueloliveiradev Aug 22, 2024
4fe79cb
feat: change http status codes in BaseResponse
migueloliveiradev Aug 22, 2024
9c604eb
fix: error null in HttpResponseMessageExtensions.GetCookies()
migueloliveiradev Aug 22, 2024
3507807
feat: refact tests and create new tests
migueloliveiradev Aug 22, 2024
e15e679
fix: change name 'Reflesh' to 'Refresh'
migueloliveiradev Aug 22, 2024
531563a
feat: new global using in web api project
migueloliveiradev Aug 22, 2024
b7498a4
fix: add exclude files .g.cs in code coverage
migueloliveiradev Aug 22, 2024
4527bc3
feat: add 'bio' and 'birthday' in register user
migueloliveiradev Aug 22, 2024
3144c56
feat: adjusts in register user
migueloliveiradev Aug 22, 2024
7c0f85f
feat: adjusts in register and login and create new tests
migueloliveiradev Aug 23, 2024
9754f60
feat: configure codecov actions
migueloliveiradev Aug 23, 2024
c1253a9
feat: change return notifications login to generic code
migueloliveiradev Aug 24, 2024
5c4d7ee
feat: added tests report in workflow
migueloliveiradev Aug 24, 2024
69d73f7
fix: update packages and ajusts in components
migueloliveiradev Aug 25, 2024
4e19de7
fix: npm audit fix
migueloliveiradev Aug 25, 2024
b95400f
feat: configuration eslint
migueloliveiradev Aug 25, 2024
7a67a62
feat: created composables useApi and useForm
migueloliveiradev Aug 27, 2024
49855e6
feat: add configurations project
migueloliveiradev Sep 1, 2024
2955944
fix: adjusts bio not required
migueloliveiradev Sep 3, 2024
acde7cb
feat: created testes to get me user
migueloliveiradev Sep 3, 2024
4d2c3a1
feat: general adjusts in webapi
migueloliveiradev Sep 3, 2024
012acce
fix: add working-directory in workflows
migueloliveiradev Sep 3, 2024
c7b9426
feat: create page register, login and feed
migueloliveiradev Sep 3, 2024
d111179
Merge branch 'i4' of https://github.com/migueloliveiradev/living into i4
migueloliveiradev Sep 3, 2024
ba0e951
Merge branch 'i4' of github.com:migueloliveiradev/living into i4
migueloliveiradev Sep 3, 2024
1865b6f
feat: add cache dependency path setup node workflow
migueloliveiradev Sep 3, 2024
a258ed0
feat: configuration docker and docker compose
migueloliveiradev Sep 3, 2024
ac5d352
Merge branch 'i4' of github.com:migueloliveiradev/living into i4
migueloliveiradev Sep 3, 2024
cbec967
fix: docker command in workflow
migueloliveiradev Sep 3, 2024
d35dcf5
fix: command docker compose workflow
migueloliveiradev Sep 3, 2024
d9e40ad
fix: case name docker compose stack
migueloliveiradev Sep 3, 2024
ba34387
feat: created layout feed and page profile
migueloliveiradev Sep 4, 2024
24a10df
feat: configuration eslint
migueloliveiradev Sep 4, 2024
7d2be12
feat: rename solution 'living' to 'Living'
migueloliveiradev Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 81 additions & 15 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,51 @@

# CS8618: O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável.
dotnet_diagnostic.CS8618.severity = none
dotnet_diagnostic.MA0004.severity = none
dotnet_diagnostic.IDE0041.severity = warning
dotnet_diagnostic.MA0015.severity = none
dotnet_diagnostic.MA0007.severity = none
csharp_space_around_binary_operators = before_and_after
dotnet_diagnostic.MA0048.excluded_symbol_names = *Migrations
dotnet_diagnostic.S6605.severity = none


[*.{cs,vb}]
end_of_line = crlf
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_require_accessibility_modifiers = always:silent
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_style_require_accessibility_modifiers = always:warning
dotnet_style_coalesce_expression = false:silent
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
dotnet_style_coalesce_expression = true:none
dotnet_style_null_propagation = false:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = false:warning
dotnet_style_prefer_conditional_expression_over_return = false:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_code_quality_unused_parameters = all:warning
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
[*.cs]
#### Estilos de nomenclatura ####

Expand Down Expand Up @@ -67,20 +101,52 @@ csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_using_directive_placement = outside_namespace:silent
csharp_style_expression_bodied_local_functions = true:warning
csharp_using_directive_placement = outside_namespace:warning
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_not_pattern = true:warning
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:silent
csharp_style_var_for_built_in_types = true:warning
csharp_style_var_when_type_is_apparent = true:warning
csharp_style_var_elsewhere = true:warning
csharp_prefer_static_local_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_indent_labels = one_less_than_current
csharp_style_prefer_readonly_struct_member = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:warning
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_style_conditional_delegate_call = true:suggestion
csharp_prefer_simple_using_statement = true:warning
csharp_prefer_braces = false:warning
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:warning

# MA0006: Use String.Equals instead of equality operator
dotnet_diagnostic.MA0006.severity = none

# MA0016: Prefer using collection abstraction instead of implementation
dotnet_diagnostic.MA0016.severity = none

[*.vb]
#### Estilos de nomenclatura ####
Expand Down
80 changes: 45 additions & 35 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Workflow responsible for validating the project's build, tests and code coverage when creating a pull request

name: 'Checks'
name: "Checks"

on:
pull_request:
Expand All @@ -14,37 +14,47 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Tests
run: dotnet test --configuration Release --logger GitHubActions /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=../coverage/ /p:ExcludeByFile="**/*Migrations/*.cs"

- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: false # throws failure if code coverage does not reach the configured thresholds
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 40'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
path: code-coverage-results.md
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: './Living.WebAPP/package-lock.json'

- name: Install dependencies
run: npm i
working-directory: Living.WebAPP

- name: Run Build
run: npm run build
working-directory: Living.WebAPP

- name: Run Lint
run: npm run lint
working-directory: Living.WebAPP

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Tests
run: dotnet test --configuration Release --logger GitHubActions --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=../coverage/ /p:ExcludeByFile="**/*Migrations/*.cs" /p:ExcludeByFile="**/*.g.cs"

- name: Tests Reporter
uses: bibipkins/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-title: "Test Results"
results-path: ./**/TestResults/*.trx
coverage-path: ./coverage/coverage.cobertura.xml
coverage-type: cobertura
coverage-threshold: 0
15 changes: 15 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Docker"

on:
pull_request:

jobs:
docker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Docker build
run: docker compose -f docker-compose.yml build
working-directory: .
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.formatOnSave": true,
"eslint.format.enable": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"[vue]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
8 changes: 6 additions & 2 deletions Living.Application/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
global using MediatR;
global using Living.Domain.Base;
global using Living.Domain.Base;
global using Living.Domain.Features.Users.Interfaces;
global using Living.Shared.Handlers;
global using MediatR;
global using Microsoft.EntityFrameworkCore;
global using System.Net;
15 changes: 12 additions & 3 deletions Living.Application/Living.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="MediatR.Extensions.FluentValidation.AspNetCore" Version="5.1.0" />
<PackageReference Include="MediatR" Version="12.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -24,6 +32,7 @@

<ItemGroup>
<ProjectReference Include="..\Living.Domain\Living.Domain.csproj" />
<ProjectReference Include="..\Living.Shared\Living.Shared.csproj" />
</ItemGroup>

</Project>
6 changes: 0 additions & 6 deletions Living.Application/Mapping/BaseProfile.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Living.Application/Mapping/Users/UserProfile.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Living.Domain.Entities.Posts;
using Living.Domain.Features.Posts.Enums;

namespace Living.Application.UseCases.Posts.Create;
public class CreatePostCommand : IRequest<BaseResponse<Guid>>
Expand Down
6 changes: 3 additions & 3 deletions Living.Application/UseCases/Posts/Create/CreatePostHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Living.Application.UseCases.Posts.Create;
public class CreatePostHandler : IRequestHandler<CreatePostCommand, BaseResponse<Guid>>
public class CreatePostHandler(IUnitOfWork unitOfWork) : Handler(unitOfWork), IRequestHandler<CreatePostCommand, BaseResponse<Guid>>
{
public async Task<BaseResponse<Guid>> Handle(CreatePostCommand request, CancellationToken cancellationToken)
public Task<BaseResponse<Guid>> Handle(CreatePostCommand request, CancellationToken cancellationToken)
{
return new(Guid.NewGuid());
return Task.FromResult(new BaseResponse<Guid>(Guid.NewGuid()));
}
}
15 changes: 0 additions & 15 deletions Living.Application/UseCases/Posts/Create/CreatePostValidator.cs

This file was deleted.

25 changes: 4 additions & 21 deletions Living.Application/UseCases/Users/Login/LoginUserCommand.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
using FluentValidation;
using Microsoft.AspNetCore.Http;

namespace Living.Application.UseCases.Users.Login;
public class LoginUserCommand : IRequest<IResult>
namespace Living.Application.UseCases.Users.Login;
public class LoginUserCommand : IRequest<BaseResponse>
{
public string Email { get; set; } = null!;
public string Password { get; set; } = null!;

public bool UseCookies { get; set; } = true;
}

public class LoginCommandValidator : AbstractValidator<LoginUserCommand>
{
public LoginCommandValidator()
{
RuleFor(x => x.Email)
.NotEmpty().WithErrorCode("IS_REQUIRED")
.EmailAddress().WithErrorCode("IS_EMAIL");
RuleFor(x => x.Password)
.NotEmpty().WithErrorCode("IS_REQUIRED");
}
public string EmailOrUsername { get; set; }
public string Password { get; set; }
}
Loading