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

[#125] Refactor: properties 파일 리팩토링 #126

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM openjdk:17-alpine
CMD ["./gradlew", "clean", "build"]
ARG JAR_FILE_PATH=build/libs/devrace-backend-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE_PATH} app.jar
ENTRYPOINT ["java", "-Dspring.profiles.active=prod,swagger,mongodb,oauth,bucket", "-jar", "app.jar"]
ENTRYPOINT ["java", "-Dspring.profiles.active=prod,secret", "-jar", "app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class AwsS3Config {
@Value("${cloud.aws.region.static}")
private String region;


@Bean
public AmazonS3Client amazonS3Client() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
Expand Down
29 changes: 20 additions & 9 deletions src/main/java/com/sajang/devracebackend/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.List;

@Configuration
public class SwaggerConfig {

@Value("${server.env}")
private String serverEnv;
@Value("${server.url}")
private String serverUrl;


@Bean
public OpenAPI openAPI() {

String authName = "JWT"; // 기능 타이틀명
SecurityRequirement securityRequirement = new SecurityRequirement().addList(authName);

Expand All @@ -31,18 +38,11 @@ public OpenAPI openAPI() {
.description("'Bearer '을 제외한 Access Token 입력하세요.")
);

Server localServer = new Server();
localServer.description("Http local server")
.url("http://localhost:8080");
Server prodServer = new Server();
prodServer.description("Https prod server")
.url("https://www.dev-race.site");

return new OpenAPI()
.addSecurityItem(securityRequirement)
.components(components)
.info(apiInfo())
.servers(Arrays.asList(prodServer, localServer));
.servers(apiServer());
}

private Info apiInfo() {
Expand All @@ -51,4 +51,15 @@ private Info apiInfo() {
.description("<a href=\"https://sahyunjin.notion.site/2071d1695b254b78a1367ef555d6b820?v=336213c0a3b345f28fdb4ef181044d31&pvs=4\" target=\"blank\">Rest API 명세서</a> / <a href=\"https://sahyunjin.notion.site/2e577f50c85648cdaae86aeeae66be5a?v=a717219fcb494da39e765bea246b6cfd&pvs=4\" target=\"blank\">WebSocket API 명세서</a>")
.version("1.0.0");
}

private List<Server> apiServer() {
String description = "Local Server";
if(serverEnv.equals("prod")) description = "Prod Server";

Server server = new Server()
.description(description)
.url(serverUrl);

return Arrays.asList(server);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static UserSolvedResponseDto getSolvedCount(String bojId) { // WebClient
.bodyToMono(UserSolvedResponseDto.class)
.block();
} catch (Exception e){
throw new Exception404.NoSuchBojId(String.format("bojId = %d", bojId)); // solvedac 서버에 존재하지않는 백준id일경우 예외 처리.
throw new Exception404.NoSuchBojId("bojId = " + bojId); // solvedac 서버에 존재하지않는 백준id일경우 예외 처리.
}
}
}
18 changes: 17 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@ spring.mvc.pathmatch.matching-strategy=ant_path_matcher
spring.servlet.multipart.maxFileSize=30MB
spring.servlet.multipart.maxRequestSize=30MB

spring.profiles.active=local,swagger,mongodb,oauth,bucket
## Swagger
springdoc.packages-to-scan=com.sajang.devracebackend.controller
springdoc.default-consumes-media-type=application/json;charset=UTF-8
springdoc.default-produces-media-type=application/json;charset=UTF-8
# URI + /swagger
springdoc.swagger-ui.path=/swagger
springdoc.swagger-ui.disable-swagger-default-url=true
springdoc.writer-with-default-pretty-printer=true
# true: show Checking API response time
springdoc.swagger-ui.display-request-duration=false
# alpha: sort by Alphabet, method: sort by HTTP status code
springdoc.swagger-ui.operations-sorter=alpha
# Disabled to cause 'Test' Tag to go down.
# springdoc.swagger-ui.tags-sorter=alpha

## Profile
spring.profiles.active=local,secret
9 changes: 6 additions & 3 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<title>OAuth2 Test html</title>
</head>
<body>
<a href="/oauth2/authorization/google">Google Login</a><br>
<a href="/oauth2/authorization/github">Github Login</a><br>
<br><br><br>
<div align="center">
<h2><a href="/oauth2/authorization/google">Google Login</a></h2>
<h2><a href="/oauth2/authorization/github">Github Login</a></h2>
</div>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion submodule-backend
Loading