Skip to content

Commit ec85eb2

Browse files
authored
fix: prepare cloud (#6)
2 parents 5258758 + c2b2c45 commit ec85eb2

File tree

9 files changed

+65
-47
lines changed

9 files changed

+65
-47
lines changed

compose-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ services:
88
- "POSTGRES_PASSWORD=backend"
99
- "POSTGRES_USER=backend"
1010
ports:
11-
- 5432:5432
11+
- 5003:5432

compose.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

pom.xml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
<groupId>br.com.grupo63.techchallenge</groupId>
1212
<artifactId>service-payment</artifactId>
1313
<version>4.3.2</version>
14-
<name>service-payment</name>
14+
<name>Service Payment</name>
1515
<description>FIAP SOAT1 2023 - Group 63 - Payment microservice</description>
1616
<properties>
1717
<java.version>17</java.version>
1818

1919
<sonar.coverage.exclusions>
20-
**/config/*
20+
**/config/*,
21+
**/dto/*DTO.*,
2122
</sonar.coverage.exclusions>
2223
</properties>
2324

@@ -32,7 +33,7 @@
3233
<dependency>
3334
<groupId>com.github.soat-tech-challenge</groupId>
3435
<artifactId>service-common</artifactId>
35-
<version>4.2.0</version>
36+
<version>4.2.2</version>
3637
</dependency>
3738
<dependency>
3839
<groupId>org.springframework.boot</groupId>
@@ -136,8 +137,18 @@
136137
</exclude>
137138
</excludes>
138139
</configuration>
140+
<executions>
141+
<execution>
142+
<goals>
143+
<goal>build-info</goal>
144+
</goals>
145+
</execution>
146+
</executions>
147+
</plugin>
148+
<plugin>
149+
<groupId>io.github.git-commit-id</groupId>
150+
<artifactId>git-commit-id-maven-plugin</artifactId>
139151
</plugin>
140-
141152
<plugin>
142153
<groupId>org.apache.maven.plugins</groupId>
143154
<artifactId>maven-surefire-plugin</artifactId>
@@ -179,11 +190,8 @@
179190
<version>0.8.11</version>
180191
<configuration>
181192
<excludes>
182-
<exclude>**/br/com/grupo63/techchallenge/payment/api/controller/dto/PaymentStatusResponseDTO.class</exclude>
183-
<exclude>**/br/com/grupo63/techchallenge/payment/api/controller/dto/QRCodeResponseDTO.class</exclude>
184-
<exclude>**/br/com/grupo63/techchallenge/payment/gateway/order/dto/OrderDTO.class</exclude>
185-
<exclude>**/br/com/grupo63/techchallenge/payment/config/JwtFilterConfig.class</exclude>
186-
<exclude>**/br/com/grupo63/techchallenge/payment/config/JwtService.class</exclude>
193+
<exclude>**/dto/*DTO.*</exclude>
194+
<exclude>**/config/**</exclude>
187195
<exclude>**/br/com/grupo63/techchallenge/payment/ServicePaymentApplication.class</exclude>
188196
</excludes>
189197
</configuration>

src/main/java/br/com/grupo63/techchallenge/payment/ServicePaymentApplication.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
package br.com.grupo63.techchallenge.payment;
22

3+
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
34
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
45
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
6+
import io.swagger.v3.oas.annotations.info.Info;
57
import io.swagger.v3.oas.annotations.security.SecurityScheme;
8+
import io.swagger.v3.oas.annotations.servers.Server;
69
import org.springframework.boot.SpringApplication;
710
import org.springframework.boot.autoconfigure.SpringBootApplication;
811
import org.springframework.cloud.openfeign.EnableFeignClients;
912

1013
@SpringBootApplication
1114
@EnableFeignClients
15+
@OpenAPIDefinition(
16+
info = @Info(title = "${info.name}", description = "${info.description}", version = "${info.version}"),
17+
18+
servers ={
19+
@Server(url = "${server.servlet.context-path:}", description = "Current URL"),
20+
@Server(url = "localhost:${server.port:8080}${server.servlet.context-path:}", description = "Localhost"),
21+
@Server(url = "${app.docs-api-url:(no value)}${server.servlet.context-path:}", description = "Custom URL from env")
22+
})
1223
@SecurityScheme(
1324
name = "bearerAuth",
1425
type = SecuritySchemeType.HTTP,

src/main/java/br/com/grupo63/techchallenge/payment/gateway/order/IOrderGateway.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import java.util.Optional;
1010

11-
@FeignClient(name = "orders", url = "${urls.baseurl-order}")
11+
@FeignClient(name = "orders", url = "${app.api-url.order}")
1212
public interface IOrderGateway {
1313

14-
@RequestMapping(method = RequestMethod.GET, value = "${urls.orders}/{orderId}")
14+
@RequestMapping(method = RequestMethod.GET, value = "/orders/{orderId}")
1515
Optional<OrderDTO> getOrderById(@PathVariable("orderId") Long orderId);
1616

1717
}

src/main/java/br/com/grupo63/techchallenge/payment/gateway/status/IStatusGateway.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import org.springframework.web.bind.annotation.RequestMethod;
66
import org.springframework.web.bind.annotation.RequestParam;
77

8-
@FeignClient(name = "status", url = "${urls.baseurl-production}")
8+
@FeignClient(name = "status", url = "${app.api-url.production}")
99
public interface IStatusGateway {
1010

11-
@RequestMapping(method = RequestMethod.POST, value = "${urls.status}/advance-status", consumes = "application/json")
11+
@RequestMapping(method = RequestMethod.POST, value = "/status/advance-status", consumes = "application/json")
1212
void advanceStatus(@RequestParam("orderId") Long orderId);
1313

1414
}

src/main/resources/application-dev.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ spring:
22
datasource:
33
driver-class-name: org.postgresql.Driver
44
password: ${DB_PASSWORD:backend}
5-
url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:backend}
5+
url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5003}/${DB_NAME:backend}
66
username: ${DB_USERNAME:backend}
77
docker:
88
compose:
@@ -18,14 +18,16 @@ spring:
1818
flyway:
1919
locations: classpath:db/migrations/{vendor}/
2020
enabled: true
21+
22+
# --- Custom keys ---
23+
24+
app:
25+
api-url:
26+
order: "${API_URL_ORDER:http://localhost:8002/order}"
27+
production: "${API_URL_PRODUCTION:http://localhost:8004/production}"
28+
2129
jwt:
2230
token:
2331
key:
2432
public: "${JWT_PUBLIC_KEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqStd8n4SGNM0eZhV/hzU+urHA5/IMZPoP9YQ9ZcLKWiX33nI6bSuZMCrLZcJExf63xS+uxDpGxM8Mnk2zOdl+lPwANXLzP1us5P1PyA3YPycW9J7C5YTQW0GiEL3M93ZX7vMJiVoBYblP3JPlYnoYlBORuc0JPk33KtfEZP+78qXpPHM8imYrJLe8ceiDLLFDU/nh5KC2dWAy3ci1ahoJ1Q9ELhp3IZLvOTX57H/T2VKOYOya5+ST41h+JjzI+qGTVnLcKaW+k25YLlVnkSspvdx98+yQDi7kbOTS6yRZHUPD6wPk/nUozpD0nZKccoH4W+zMwmQVtsAA6JCA9gfGwIDAQAB}"
25-
urls:
26-
baseurl-order: '${BASE_URL_ORDER:http://localhost:8083}'
27-
baseurl-production: '${BASE_URL_PRODUCTION:http://localhost:8082}'
2833

29-
server:
30-
servlet:
31-
context-path: "/payment"

src/main/resources/application-prod.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ spring:
66
username: ${DB_USERNAME:backend}
77
devtools:
88
add-properties: false
9-
urls:
10-
baseurl: '/'

src/main/resources/application.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ spring:
1414
flyway:
1515
locations: classpath:db/migrations/{vendor}/
1616
enabled: true
17-
jwt:
18-
token:
19-
key:
20-
public: "${JWT_PUBLIC_KEY}"
2117

2218
springdoc:
2319
swagger-ui:
@@ -31,19 +27,31 @@ management:
3127
endpoint:
3228
health:
3329
show-components: always
30+
shutdown:
31+
enabled: true # For debugging
3432
endpoints:
3533
web:
3634
exposure:
37-
include: health, info
38-
info:
39-
name: '@project.name@'
40-
description: '@project.description@'
41-
version: '@project.version@'
35+
include: health, info, metrics, shutdown
36+
server:
37+
servlet:
38+
context-path: "/payment"
39+
port: 8003
40+
41+
# --- Custom keys ---
4242

43-
docs:
44-
api:
45-
url: "${DOCS_API_URL:https://9ah1j49vm1.execute-api.us-east-2.amazonaws.com}"
43+
app:
44+
docs-api-url: "${DOCS_API_URL:(no value)}"
45+
api-url:
46+
order: "${API_URL_ORDER}"
47+
production: "${API_URL_PRODUCTION}"
4648

47-
urls:
48-
status: '/production/status'
49-
orders: '/order/orders'
49+
info:
50+
name: "@project.name@"
51+
description: "@project.description@"
52+
version: "@project.version@"
53+
54+
jwt:
55+
token:
56+
key:
57+
public: "${JWT_PUBLIC_KEY}"

0 commit comments

Comments
 (0)