Skip to content

Commit

Permalink
fix: organize custom config keys and imports (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-otn authored Jan 27, 2024
2 parents 327c1f5 + 8c8e988 commit d8de419
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 58 deletions.
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.servers.Servers;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@OpenAPIDefinition(
info = @Info(title = "${info.name}", description = "${info.description}", version = "${info.version}"),
info = @Info(title = "${info.name}", description = "${git.commit.id}", version = "${info.version}"),

servers ={
@Server(url = "/", description = "Current URL"),
@Server(url = "localhost:8080", description = "Local"),
@Server(url = "${docs.api.url}", description = "API Gateway Invoke URL")
@Server(url = "${server.servlet.context-path:}", description = "Current URL"),
@Server(url = "localhost:${server.port:8080}${server.servlet.context-path:}", description = "Localhost"),
@Server(url = "${app.docs-api-url:(no value)}${server.servlet.context-path:}", description = "Custom URL from env")
})
@SecurityScheme(
name = "bearerAuth",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package br.com.grupo63.techchallenge.adapter;

import br.com.grupo63.techchallenge.api.controller.order.dto.AdvanceOrderStatusResponseDTO;
import br.com.grupo63.techchallenge.api.controller.order.dto.CreateOrderRequestDTO;
import br.com.grupo63.techchallenge.controller.dto.ClientControllerDTO;
import br.com.grupo63.techchallenge.controller.dto.OrderControllerDTO;
import br.com.grupo63.techchallenge.controller.dto.OrderItemControllerDTO;
import br.com.grupo63.techchallenge.entity.client.Client;
import br.com.grupo63.techchallenge.entity.order.Order;
import br.com.grupo63.techchallenge.entity.order.OrderItem;
import br.com.grupo63.techchallenge.entity.order.OrderStatus;
import br.com.grupo63.techchallenge.entity.payment.Payment;
import br.com.grupo63.techchallenge.entity.product.Product;
import br.com.grupo63.techchallenge.presenter.ClientPresenter;
import br.com.grupo63.techchallenge.presenter.PaymentPresenter;

import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package br.com.grupo63.techchallenge.adapter;

import br.com.grupo63.techchallenge.api.controller.payment.dto.PaymentStatusResponseDTO;
import br.com.grupo63.techchallenge.api.controller.payment.dto.QRCodeResponseDTO;
import br.com.grupo63.techchallenge.controller.dto.PaymentControllerDTO;
import br.com.grupo63.techchallenge.entity.payment.Payment;
import br.com.grupo63.techchallenge.entity.payment.PaymentStatus;

public class PaymentAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import br.com.grupo63.techchallenge.controller.dto.ClientControllerDTO;
import br.com.grupo63.techchallenge.exception.NotFoundException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package br.com.grupo63.techchallenge.api.controller.order.dto;

import br.com.grupo63.techchallenge.controller.dto.ClientControllerDTO;
import br.com.grupo63.techchallenge.controller.dto.OrderControllerDTO;
import br.com.grupo63.techchallenge.controller.dto.OrderItemControllerDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
import br.com.grupo63.techchallenge.TechchallengeApplication;
import io.jsonwebtoken.Claims;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

@RequiredArgsConstructor
public class JwtFilter implements Filter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.Collections;

@Configuration
public class JwtFilterConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

Expand All @@ -16,7 +15,7 @@
@Service
public class JwtService {

@Value("${jwt.token.key.public}")
@Value("${app.jwt-pub-key}")
private String jwtSigningKey;

public Claims getClaims(String token) throws NoSuchAlgorithmException, InvalidKeySpecException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package br.com.grupo63.techchallenge.gateway.client;

import br.com.grupo63.techchallenge.gateway.repository.IJpaRepository;
import br.com.grupo63.techchallenge.gateway.client.entity.ClientPersistenceEntity;
import br.com.grupo63.techchallenge.gateway.repository.IJpaRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package br.com.grupo63.techchallenge.gateway.order;

import br.com.grupo63.techchallenge.gateway.repository.IJpaRepository;
import br.com.grupo63.techchallenge.gateway.order.entity.OrderPersistenceEntity;
import br.com.grupo63.techchallenge.gateway.repository.IJpaRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package br.com.grupo63.techchallenge.gateway.order.entity;

import br.com.grupo63.techchallenge.entity.order.OrderItem;
import br.com.grupo63.techchallenge.gateway.repository.entity.PersistenceEntity;
import br.com.grupo63.techchallenge.gateway.product.entity.ProductPersistenceEntity;
import br.com.grupo63.techchallenge.gateway.repository.entity.PersistenceEntity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import br.com.grupo63.techchallenge.entity.order.Order;
import br.com.grupo63.techchallenge.entity.order.OrderStatus;
import br.com.grupo63.techchallenge.gateway.repository.entity.PersistenceEntity;
import br.com.grupo63.techchallenge.gateway.client.entity.ClientPersistenceEntity;
import br.com.grupo63.techchallenge.gateway.repository.entity.PersistenceEntity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package br.com.grupo63.techchallenge.gateway.product;

import br.com.grupo63.techchallenge.gateway.repository.IJpaRepository;
import br.com.grupo63.techchallenge.gateway.product.entity.ProductPersistenceEntity;
import br.com.grupo63.techchallenge.gateway.repository.IJpaRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package br.com.grupo63.techchallenge.presenter;

import br.com.grupo63.techchallenge.api.controller.order.dto.AdvanceOrderStatusResponseDTO;
import br.com.grupo63.techchallenge.api.controller.order.dto.CreateOrderRequestDTO;
import br.com.grupo63.techchallenge.controller.dto.ClientControllerDTO;
import br.com.grupo63.techchallenge.controller.dto.OrderControllerDTO;
import br.com.grupo63.techchallenge.controller.dto.OrderItemControllerDTO;
import br.com.grupo63.techchallenge.entity.order.Order;
import br.com.grupo63.techchallenge.entity.order.OrderStatus;

import java.util.stream.Collectors;

public class OrderPresenter {

public static OrderControllerDTO toDto(Order entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import br.com.grupo63.techchallenge.entity.payment.Payment;
import br.com.grupo63.techchallenge.entity.payment.PaymentMethod;
import br.com.grupo63.techchallenge.entity.payment.PaymentStatus;
import br.com.grupo63.techchallenge.exception.NotFoundException;
import br.com.grupo63.techchallenge.exception.ValidationException;
import br.com.grupo63.techchallenge.gateway.payment.IMercadoPagoGateway;
import br.com.grupo63.techchallenge.usecase.order.OrderUseCase;
Expand Down
7 changes: 3 additions & 4 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spring:
flyway:
locations: classpath:db/migrations/{vendor}/
enabled: true
jwt:
token:
key:
public: "${JWT_PUBLIC_KEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqStd8n4SGNM0eZhV/hzU+urHA5/IMZPoP9YQ9ZcLKWiX33nI6bSuZMCrLZcJExf63xS+uxDpGxM8Mnk2zOdl+lPwANXLzP1us5P1PyA3YPycW9J7C5YTQW0GiEL3M93ZX7vMJiVoBYblP3JPlYnoYlBORuc0JPk33KtfEZP+78qXpPHM8imYrJLe8ceiDLLFDU/nh5KC2dWAy3ci1ahoJ1Q9ELhp3IZLvOTX57H/T2VKOYOya5+ST41h+JjzI+qGTVnLcKaW+k25YLlVnkSspvdx98+yQDi7kbOTS6yRZHUPD6wPk/nUozpD0nZKccoH4W+zMwmQVtsAA6JCA9gfGwIDAQAB}"


# --- Custom keys ---
3 changes: 3 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ spring:
username: ${DB_USERNAME:backend}
devtools:
add-properties: false


# --- Custom keys ---
25 changes: 14 additions & 11 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Global config
# --- Global config ---
spring:
docker:
compose:
Expand All @@ -14,32 +14,35 @@ spring:
flyway:
locations: classpath:db/migrations/{vendor}/
enabled: true
jwt:
token:
key:
public: "${JWT_PUBLIC_KEY}"

springdoc:
swagger-ui:
path: /
tags-sorter: alpha
show-actuator: true

management:
info:
env:
enabled: true
endpoint:
health:
show-components: always
shutdown:
enabled: true # For debugging
endpoints:
web:
exposure:
include: health, info
include: health, info, metrics, shutdown


# --- Custom keys ---

app:
docs-api-url: "${DOCS_API_URL:(no value)}"
jwt-pub-key: "${JWT_PUBLIC_KEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqStd8n4SGNM0eZhV/hzU+urHA5/IMZPoP9YQ9ZcLKWiX33nI6bSuZMCrLZcJExf63xS+uxDpGxM8Mnk2zOdl+lPwANXLzP1us5P1PyA3YPycW9J7C5YTQW0GiEL3M93ZX7vMJiVoBYblP3JPlYnoYlBORuc0JPk33KtfEZP+78qXpPHM8imYrJLe8ceiDLLFDU/nh5KC2dWAy3ci1ahoJ1Q9ELhp3IZLvOTX57H/T2VKOYOya5+ST41h+JjzI+qGTVnLcKaW+k25YLlVnkSspvdx98+yQDi7kbOTS6yRZHUPD6wPk/nUozpD0nZKccoH4W+zMwmQVtsAA6JCA9gfGwIDAQAB}"

info:
name: '@project.name@'
description: '@project.description@'
version: '@project.version@'

docs:
api:
url: "${DOCS_API_URL:https://9ah1j49vm1.execute-api.us-east-2.amazonaws.com}"
version: '@project.version@'
12 changes: 5 additions & 7 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
app:
version: '@project.version@'
springdoc:
api-docs:
enabled: false
Expand All @@ -24,12 +22,12 @@ spring:
compose:
enabled: false

jwt:
token:
key:
public: "${JWT_PUBLIC_KEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoNgzDuoQFLRFb3ivIA5CEHFRuqltT7xR6hFu+6xPD5q0sq8Exjue5s5MIQwkJMldk8/Dhp85OT5ULmAA5x4hPZfFlQEMlMPT5QItQImQ7UFCxBbMwksZlUQEP37Aa5OJ+KhEPBDTe0AaXqXFKxIOLEjHYWqhFHq5whxNotbuPrqLWEopCAgY4lqCe0pSoT3V+7Jszpq+czLBOl6eCbD933pK98/aVD9yA2+7LNOwmkYVyR4kvXX25K5Q/DDUZgMWyQTm3TCnfCrbdH6IH/Z12/DkePNuGFygUKDCEYPkPYnHbRXee4CXbeDkEdgZwzGJPM8gPhSUFrrzFVeihvN5OQIDAQAB}"

management:
endpoints:
enabled-by-default: false


# --- Custom keys ---

app:
jwt-pub-key: "${JWT_PUBLIC_KEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqStd8n4SGNM0eZhV/hzU+urHA5/IMZPoP9YQ9ZcLKWiX33nI6bSuZMCrLZcJExf63xS+uxDpGxM8Mnk2zOdl+lPwANXLzP1us5P1PyA3YPycW9J7C5YTQW0GiEL3M93ZX7vMJiVoBYblP3JPlYnoYlBORuc0JPk33KtfEZP+78qXpPHM8imYrJLe8ceiDLLFDU/nh5KC2dWAy3ci1ahoJ1Q9ELhp3IZLvOTX57H/T2VKOYOya5+ST41h+JjzI+qGTVnLcKaW+k25YLlVnkSspvdx98+yQDi7kbOTS6yRZHUPD6wPk/nUozpD0nZKccoH4W+zMwmQVtsAA6JCA9gfGwIDAQAB}"

0 comments on commit d8de419

Please sign in to comment.