diff --git a/grida-clients/kakao-client/src/main/kotlin/org/grida/config/KakaoProperties.kt b/grida-clients/kakao-client/src/main/kotlin/org/grida/config/KakaoProperties.kt index 651e6cca..9fb0ff77 100644 --- a/grida-clients/kakao-client/src/main/kotlin/org/grida/config/KakaoProperties.kt +++ b/grida-clients/kakao-client/src/main/kotlin/org/grida/config/KakaoProperties.kt @@ -7,5 +7,8 @@ import org.springframework.boot.context.properties.ConstructorBinding @ConfigurationProperties("kakao") data class KakaoProperties( val appKey: String, - val redirectUri: String -) + val baseUri: String, + val apiPath: String +) { + val redirectUri: String = baseUri + apiPath +} diff --git a/grida-clients/kakao-client/src/main/resources/application-kakao-client.yml b/grida-clients/kakao-client/src/main/resources/application-kakao-client.yml new file mode 100644 index 00000000..989e5711 --- /dev/null +++ b/grida-clients/kakao-client/src/main/resources/application-kakao-client.yml @@ -0,0 +1,19 @@ +--- +spring: + config: + activate: + on-profile: dev +kakao: + appKey: ${KAKAO_APP_KEY} + base-uri: http://localhost:8080 + api-path: ${KAKAO_REDIRECT_URL} + +--- +spring: + config: + activate: + on-profile: prod +kakao: + appKey: ${KAKAO_APP_KEY} + base-uri: https://grida.today + api-path: ${KAKAO_REDIRECT_URL} diff --git a/grida-clients/openai-client/src/main/resources/application-openai-client.yml b/grida-clients/openai-client/src/main/resources/application-openai-client.yml new file mode 100644 index 00000000..dd9233a1 --- /dev/null +++ b/grida-clients/openai-client/src/main/resources/application-openai-client.yml @@ -0,0 +1,14 @@ +openai: + secret-key: ${OPEN_AI_SECRET_KEY} + +--- +spring: + config: + activate: + on-profile: dev + +--- +spring: + config: + activate: + on-profile: prod \ No newline at end of file diff --git a/grida-clients/openai-client/src/main/resources/application.yml b/grida-clients/openai-client/src/main/resources/application.yml deleted file mode 100644 index 16727b7b..00000000 --- a/grida-clients/openai-client/src/main/resources/application.yml +++ /dev/null @@ -1,2 +0,0 @@ -openai: - secret-ket: ${OPEN_AI_SECRET_KEY} \ No newline at end of file diff --git a/grida-clients/storage-client/build.gradle.kts b/grida-clients/s3-client/build.gradle.kts similarity index 100% rename from grida-clients/storage-client/build.gradle.kts rename to grida-clients/s3-client/build.gradle.kts diff --git a/grida-clients/storage-client/src/main/kotlin/org/grida/FileMetaData.kt b/grida-clients/s3-client/src/main/kotlin/org/grida/FileMetaData.kt similarity index 100% rename from grida-clients/storage-client/src/main/kotlin/org/grida/FileMetaData.kt rename to grida-clients/s3-client/src/main/kotlin/org/grida/FileMetaData.kt diff --git a/grida-clients/storage-client/src/main/kotlin/org/grida/StorageClient.kt b/grida-clients/s3-client/src/main/kotlin/org/grida/S3Client.kt similarity index 84% rename from grida-clients/storage-client/src/main/kotlin/org/grida/StorageClient.kt rename to grida-clients/s3-client/src/main/kotlin/org/grida/S3Client.kt index e8921036..049bfea5 100644 --- a/grida-clients/storage-client/src/main/kotlin/org/grida/StorageClient.kt +++ b/grida-clients/s3-client/src/main/kotlin/org/grida/S3Client.kt @@ -2,15 +2,15 @@ package org.grida import com.amazonaws.AmazonClientException import com.amazonaws.services.s3.AmazonS3 -import org.grida.config.StorageClientProperties +import org.grida.config.S3ClientProperties import org.grida.error.FileUploadFail import org.grida.error.GridaException import org.springframework.stereotype.Component import java.io.File @Component -class StorageClient( - private val properties: StorageClientProperties, +class S3Client( + private val properties: S3ClientProperties, private val amazonS3: AmazonS3, ) { fun uploadFile( diff --git a/grida-clients/storage-client/src/main/kotlin/org/grida/config/StorageClientConfig.kt b/grida-clients/s3-client/src/main/kotlin/org/grida/config/S3ClientConfig.kt similarity index 83% rename from grida-clients/storage-client/src/main/kotlin/org/grida/config/StorageClientConfig.kt rename to grida-clients/s3-client/src/main/kotlin/org/grida/config/S3ClientConfig.kt index a0b254db..54425aa1 100644 --- a/grida-clients/storage-client/src/main/kotlin/org/grida/config/StorageClientConfig.kt +++ b/grida-clients/s3-client/src/main/kotlin/org/grida/config/S3ClientConfig.kt @@ -10,11 +10,11 @@ import org.springframework.context.annotation.Configuration @Configuration @ConfigurationPropertiesScan -class StorageClientConfig( - private val properties: StorageClientProperties, +class S3ClientConfig( + private val properties: S3ClientProperties, ) { @Bean - fun amazonS3Client(properties: StorageClientProperties): AmazonS3 { + fun amazonS3Client(properties: S3ClientProperties): AmazonS3 { val credential = BasicAWSCredentials(properties.accessKey, properties.secretKey) return AmazonS3ClientBuilder diff --git a/grida-clients/storage-client/src/main/kotlin/org/grida/config/StorageClientProperties.kt b/grida-clients/s3-client/src/main/kotlin/org/grida/config/S3ClientProperties.kt similarity index 90% rename from grida-clients/storage-client/src/main/kotlin/org/grida/config/StorageClientProperties.kt rename to grida-clients/s3-client/src/main/kotlin/org/grida/config/S3ClientProperties.kt index 68f8b105..0a92f1c4 100644 --- a/grida-clients/storage-client/src/main/kotlin/org/grida/config/StorageClientProperties.kt +++ b/grida-clients/s3-client/src/main/kotlin/org/grida/config/S3ClientProperties.kt @@ -5,7 +5,7 @@ import org.springframework.boot.context.properties.ConstructorBinding @ConstructorBinding @ConfigurationProperties("storage.aws") -data class StorageClientProperties( +data class S3ClientProperties( val accessKey: String, val secretKey: String, val region: String, diff --git a/grida-clients/storage-client/src/main/kotlin/org/grida/error/StorageClientErrorType.kt b/grida-clients/s3-client/src/main/kotlin/org/grida/error/S3ClientErrorType.kt similarity index 100% rename from grida-clients/storage-client/src/main/kotlin/org/grida/error/StorageClientErrorType.kt rename to grida-clients/s3-client/src/main/kotlin/org/grida/error/S3ClientErrorType.kt diff --git a/grida-clients/s3-client/src/main/resources/application-s3-client.yml b/grida-clients/s3-client/src/main/resources/application-s3-client.yml new file mode 100644 index 00000000..ba69664d --- /dev/null +++ b/grida-clients/s3-client/src/main/resources/application-s3-client.yml @@ -0,0 +1,18 @@ +storage: + aws: + access-key: ${S3_ACCESS_KEY} + secret-key: ${S3_SECRET_KEY} + region: ${S3_REGION} + bucket: ${S3_BUCKET} + host: ${CDN_HOST} +--- +spring: + config: + activate: + on-profile: dev + +--- +spring: + config: + activate: + on-profile: prod \ No newline at end of file diff --git a/grida-clients/storage-client/src/main/resources/application-storage-client.yml b/grida-clients/storage-client/src/main/resources/application-storage-client.yml deleted file mode 100644 index 0091d5b0..00000000 --- a/grida-clients/storage-client/src/main/resources/application-storage-client.yml +++ /dev/null @@ -1,7 +0,0 @@ -storage: - aws: - access-key: ${S3_ACCESS_KEY} - secret-key: ${S3_SECRET_KEY} - region: ${S3_REGION} - bucket: ${S3_BUCKET} - host: ${CDN_HOST} \ No newline at end of file diff --git a/grida-common/src/main/kotlin/org/grida/api/dto/ListResponse.kt b/grida-common/src/main/kotlin/org/grida/api/dto/ListResponse.kt new file mode 100644 index 00000000..b90bb163 --- /dev/null +++ b/grida-common/src/main/kotlin/org/grida/api/dto/ListResponse.kt @@ -0,0 +1,19 @@ +package org.grida.api.dto + +data class ListResponse( + val count: Int, + val list: List +) { + + companion object { + fun from( + list: List, + mapAction: () -> T + ): ListResponse { + return ListResponse( + list.size, + list.map { mapAction.invoke() } + ) + } + } +} diff --git a/grida-clients/kakao-client/src/main/resources/application.yml b/grida-common/src/main/resources/application-common.yml similarity index 100% rename from grida-clients/kakao-client/src/main/resources/application.yml rename to grida-common/src/main/resources/application-common.yml diff --git a/grida-common/src/main/resources/application-core.yml b/grida-common/src/main/resources/application-core.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/grida-core/core-api/build.gradle.kts b/grida-core/core-api/build.gradle.kts index 7095f648..a780ce55 100644 --- a/grida-core/core-api/build.gradle.kts +++ b/grida-core/core-api/build.gradle.kts @@ -5,8 +5,10 @@ plugins { dependencies { // module dependencies implementation(project(":grida-core:core-domain")) - implementation(project(":grida-database:database-rds")) + implementation(project(":grida-storage:rds-storage")) implementation(project(":grida-clients:kakao-client")) + implementation(project(":grida-support:logging")) + implementation(project(":grida-support:monitoring")) // web implementation("org.springframework.boot:spring-boot-starter-web") @@ -18,15 +20,11 @@ dependencies { implementation("com.github.wwan13:winter-security:0.0.10") // logging-request - implementation("com.github.wwan13:spring-request-logger:0.0.3") + implementation("com.github.wwan13:spring-request-logger:0.0.7") // api docs testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc") testImplementation("com.github.wwan13.kotlin-dsl-rest-docs:impl-mockmvc:1.2.9") - - // monitoring - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("io.micrometer:micrometer-registry-prometheus") } tasks { diff --git a/grida-core/core-api/http/core-api.http b/grida-core/core-api/http/core-api.http new file mode 100644 index 00000000..e7b915f1 --- /dev/null +++ b/grida-core/core-api/http/core-api.http @@ -0,0 +1,2 @@ +### Health Checking Api +GET {{core-api}}/api/health \ No newline at end of file diff --git a/grida-core/core-api/http/http-client.env.json b/grida-core/core-api/http/http-client.env.json new file mode 100644 index 00000000..0111aa38 --- /dev/null +++ b/grida-core/core-api/http/http-client.env.json @@ -0,0 +1,8 @@ +{ + "local": { + "core-api": "http://localhost:8080" + }, + "prod": { + "core-api": "https://grida.today" + } +} \ No newline at end of file diff --git a/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessor.kt b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessor.kt new file mode 100644 index 00000000..0708b6bd --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessor.kt @@ -0,0 +1,5 @@ +package org.grida.auth + +interface AuthProcessor { + fun process(code: String): AuthToken +} diff --git a/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessorSelector.kt b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessorSelector.kt new file mode 100644 index 00000000..498d714f --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessorSelector.kt @@ -0,0 +1,16 @@ +package org.grida.auth + +import org.grida.error.GridaException +import org.grida.error.NotSupportedLoginPlatform +import org.springframework.stereotype.Component + +@Component +class AuthProcessorSelector( + private val authProcessors: Map +) { + + fun select(platform: String): AuthProcessor { + return authProcessors["${platform}AuthProcessor"] + ?: throw GridaException(NotSupportedLoginPlatform) + } +} diff --git a/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthToken.kt b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthToken.kt new file mode 100644 index 00000000..ac41a5fa --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthToken.kt @@ -0,0 +1,6 @@ +package org.grida.auth + +data class AuthToken( + val accessToken: String, + val refreshToken: String +) diff --git a/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthTokenProvider.kt b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthTokenProvider.kt new file mode 100644 index 00000000..23582103 --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/auth/AuthTokenProvider.kt @@ -0,0 +1,22 @@ +package org.grida.auth + +import io.wwan13.wintersecurity.jwt.TokenGenerator +import org.grida.config.TokenPayload +import org.grida.domain.user.User +import org.springframework.stereotype.Component + +@Component +class AuthTokenProvider( + private val tokenGenerator: TokenGenerator +) { + + fun provide( + user: User + ): AuthToken { + val tokenPayload = TokenPayload(user.id, user.role) + return AuthToken( + accessToken = tokenGenerator.accessToken(tokenPayload), + refreshToken = tokenGenerator.refreshToken(tokenPayload) + ) + } +} diff --git a/grida-core/core-api/src/main/kotlin/org/grida/auth/InternalAuthProcessor.kt b/grida-core/core-api/src/main/kotlin/org/grida/auth/InternalAuthProcessor.kt new file mode 100644 index 00000000..ed21b854 --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/auth/InternalAuthProcessor.kt @@ -0,0 +1,36 @@ +package org.grida.auth + +import org.grida.domain.user.LoginOption +import org.grida.domain.user.LoginPlatform +import org.grida.domain.user.UserService +import org.grida.error.GridaException +import org.grida.error.NotSupportedLoginPlatform +import org.springframework.beans.factory.annotation.Value +import org.springframework.stereotype.Component + +@Component +class InternalAuthProcessor( + @Value("\${spring.profiles.active}") + private val activeProfile: String, + private val userService: UserService, + private val authTokenProvider: AuthTokenProvider +) : AuthProcessor { + + override fun process(code: String): AuthToken { + validateActiveProfile() + val loginOption = LoginOption(LoginPlatform.ADMIN, code) + val user = userService.read(loginOption.identifier.toLong()) + + return authTokenProvider.provide(user) + } + + private fun validateActiveProfile() { + if (!enableProfiles.contains(activeProfile)) { + throw throw GridaException(NotSupportedLoginPlatform) + } + } + + companion object { + val enableProfiles = listOf("dev", "stag") + } +} diff --git a/grida-core/core-api/src/main/kotlin/org/grida/auth/KakaoAuthProcessor.kt b/grida-core/core-api/src/main/kotlin/org/grida/auth/KakaoAuthProcessor.kt new file mode 100644 index 00000000..391e34ca --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/auth/KakaoAuthProcessor.kt @@ -0,0 +1,26 @@ +package org.grida.auth + +import org.grida.domain.user.LoginOption +import org.grida.domain.user.LoginPlatform +import org.grida.domain.user.UserService +import org.grida.user.KakaoUserClient +import org.springframework.stereotype.Component + +@Component +class KakaoAuthProcessor( + private val kakaoAuthClient: KakaoAuthClient, + private val kakaoUserClient: KakaoUserClient, + private val userService: UserService, + private val authTokenProvider: AuthTokenProvider +) : AuthProcessor { + + override fun process(code: String): AuthToken { + val kakaoToken = kakaoAuthClient.provideAuthToken(code) + val kakaoProfile = kakaoUserClient.readUserProfile(kakaoToken.accessToken) + val loginOption = LoginOption(LoginPlatform.KAKAO, kakaoProfile.id) + + val user = userService.readUserByLoginOption(loginOption) + ?: userService.appendAndReturnNormalUser(kakaoProfile.name, loginOption) + return authTokenProvider.provide(user) + } +} diff --git a/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiConfig.kt b/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiConfig.kt index 65ad2fdd..fbc2b675 100644 --- a/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiConfig.kt +++ b/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiConfig.kt @@ -1,27 +1,8 @@ package org.grida.config -import io.wwan13.springrequestlogger.configure.EnableLoggingRequest -import io.wwan13.springrequestlogger.configure.LogMessageConfigurer -import io.wwan13.springrequestlogger.context.RequestContext import org.springframework.boot.context.properties.ConfigurationPropertiesScan import org.springframework.context.annotation.Configuration -import java.util.function.Function @Configuration @ConfigurationPropertiesScan -@EnableLoggingRequest -class CoreApiConfig : LogMessageConfigurer { - - override fun format(): Function { - return Function { context -> - """ - | - | ${context.method} '${context.uri}' - ${context.status} (${context.elapsed} s) - | >> Request Headers : ${context.requestHeaders} - | >> Request Params : ${context.requestParams} - | >> Request Body : ${context.requestBody} - | >> Response Body : ${context.responseBody} - """.trimMargin() - } - } -} +class CoreApiConfig diff --git a/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiSecurityConfig.kt b/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiSecurityConfig.kt index 8ceaa490..ebad6c17 100644 --- a/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiSecurityConfig.kt +++ b/grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiSecurityConfig.kt @@ -31,6 +31,10 @@ class CoreApiSecurityConfig( override fun registerAuthPatterns(registry: AuthPatternsRegistry) { registry.apply { + uriPatterns("/api/health") + .httpMethodGet() + .permitAll() + uriPatterns("/api/v1/auth/**") .allHttpMethods() .permitAll() diff --git a/grida-core/core-api/src/main/kotlin/org/grida/config/RequestLoggingConfig.kt b/grida-core/core-api/src/main/kotlin/org/grida/config/RequestLoggingConfig.kt new file mode 100644 index 00000000..664c5925 --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/config/RequestLoggingConfig.kt @@ -0,0 +1,14 @@ +package org.grida.config + +import io.wwan13.springrequestlogger.configure.EnableLoggingRequest +import io.wwan13.springrequestlogger.configure.LogMessageConfigurer +import org.springframework.context.annotation.Configuration + +@Configuration +@EnableLoggingRequest +class RequestLoggingConfig : LogMessageConfigurer { + + override fun excludePathPatterns(): List { + return listOf("/api/actuator/**") + } +} diff --git a/grida-core/core-api/src/main/kotlin/org/grida/error/CoreApiErrorType.kt b/grida-core/core-api/src/main/kotlin/org/grida/error/CoreApiErrorType.kt index 1b884c53..533643c2 100644 --- a/grida-core/core-api/src/main/kotlin/org/grida/error/CoreApiErrorType.kt +++ b/grida-core/core-api/src/main/kotlin/org/grida/error/CoreApiErrorType.kt @@ -4,9 +4,9 @@ import org.grida.http.BAD_REQUEST sealed interface CoreApiErrorType : ErrorType -data object LoginFailed : CoreApiErrorType { +data object NotSupportedLoginPlatform : CoreApiErrorType { override val httpStatusCode: Int = BAD_REQUEST - override val errorCode: String = "AUTH_400_1" - override val message: String = "아이디 혹은 비밀번호를 확인하세요." + override val errorCode: String = "AUTH_PLATFORM_400_1" + override val message: String = "지원하지 않는 로그인 플랫폼 입니다." override val logLevel: LogLevel = INFO } diff --git a/grida-core/core-api/src/main/kotlin/org/grida/presentation/ApiControllerAdvice.kt b/grida-core/core-api/src/main/kotlin/org/grida/presentation/ApiControllerAdvice.kt index 379f5eca..d91c167c 100644 --- a/grida-core/core-api/src/main/kotlin/org/grida/presentation/ApiControllerAdvice.kt +++ b/grida-core/core-api/src/main/kotlin/org/grida/presentation/ApiControllerAdvice.kt @@ -17,6 +17,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.http.converter.HttpMessageNotReadableException import org.springframework.web.HttpRequestMethodNotSupportedException +import org.springframework.web.bind.MissingServletRequestParameterException import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.RestControllerAdvice import org.springframework.web.servlet.NoHandlerFoundException @@ -98,6 +99,15 @@ class ApiControllerAdvice { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response) } + @ExceptionHandler(MissingServletRequestParameterException::class) + fun handleMissingServletRequestParameterException( + e: MissingServletRequestParameterException + ): ResponseEntity> { + log.info(e.message) + val response = ApiResponse.error("HTTP_400", "요청에 필요한 쿼리 파라미터 ${e.parameterName}가 없습니다.") + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response) + } + @ExceptionHandler(HttpMessageNotReadableException::class) fun handleHttpMessageNotReadableException( e: HttpMessageNotReadableException diff --git a/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/AuthController.kt b/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/AuthController.kt index 260d28f2..6aa558e9 100644 --- a/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/AuthController.kt +++ b/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/AuthController.kt @@ -1,14 +1,8 @@ package org.grida.presentation.v1.auth -import io.wwan13.wintersecurity.jwt.TokenGenerator import org.grida.api.ApiResponse -import org.grida.auth.KakaoAuthClient -import org.grida.config.TokenPayload -import org.grida.domain.user.LoginOption -import org.grida.domain.user.LoginPlatform -import org.grida.domain.user.UserService +import org.grida.auth.AuthProcessorSelector import org.grida.presentation.v1.auth.dto.LoginResponse -import org.grida.user.KakaoUserClient import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam @@ -17,28 +11,17 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/v1/auth") class AuthController( - private val userService: UserService, - private val tokenGenerator: TokenGenerator, - private val kakaoAuthClient: KakaoAuthClient, - private val kakaoUserClient: KakaoUserClient + private val authProcessorSelector: AuthProcessorSelector ) { - @GetMapping("/kakao") - fun kakaoLogin( - @RequestParam("code") kakaoAuthCode: String + @GetMapping + fun provideAuthToken( + @RequestParam("platform") platform: String, + @RequestParam("code") code: String ): ApiResponse { - val kakaoToken = kakaoAuthClient.provideAuthToken(kakaoAuthCode) - val kakaoProfile = kakaoUserClient.readUserProfile(kakaoToken.accessToken) - - val loginOption = LoginOption(LoginPlatform.KAKAO, kakaoProfile.id) - val user = userService.readUserByLoginOption(loginOption) - ?: userService.appendAndReturnNormalUser(kakaoProfile.name, loginOption) - - val tokenPayload = TokenPayload(user.id, user.role) - val response = LoginResponse( - accessToken = tokenGenerator.accessToken(tokenPayload), - refreshToken = tokenGenerator.refreshToken(tokenPayload) - ) + val authProcessor = authProcessorSelector.select(platform) + val authToken = authProcessor.process(code) + val response = LoginResponse.from(authToken) return ApiResponse.success(response) } } diff --git a/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/dto/LoginRequest.kt b/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/dto/LoginRequest.kt new file mode 100644 index 00000000..61d740ce --- /dev/null +++ b/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/dto/LoginRequest.kt @@ -0,0 +1,5 @@ +package org.grida.presentation.v1.auth.dto + +data class LoginRequest( + val code: String +) diff --git a/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/dto/LoginResponse.kt b/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/dto/LoginResponse.kt index 80d357b6..47dfa569 100644 --- a/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/dto/LoginResponse.kt +++ b/grida-core/core-api/src/main/kotlin/org/grida/presentation/v1/auth/dto/LoginResponse.kt @@ -1,6 +1,14 @@ package org.grida.presentation.v1.auth.dto +import org.grida.auth.AuthToken + data class LoginResponse( val accessToken: String, val refreshToken: String, -) +) { + companion object { + fun from(authToken: AuthToken): LoginResponse { + return LoginResponse(authToken.accessToken, authToken.refreshToken) + } + } +} diff --git a/grida-core/core-api/src/main/resources/application.yml b/grida-core/core-api/src/main/resources/application.yml index 8f28461d..cb872b48 100644 --- a/grida-core/core-api/src/main/resources/application.yml +++ b/grida-core/core-api/src/main/resources/application.yml @@ -1,60 +1,24 @@ spring: + profiles: + active: dev + include: + - rds-storage + - kakao-client + - openai-client + - s3-client + - logging + - monitoring mvc: throw-exception-if-no-handler-found: true web: resources: add-mappings: false - datasource: - url: ${DATASOURCE_URL} - username: ${DATABASE_USERNAME} - password: ${DATABASE_PASSWORD} - driver-class-name: com.mysql.cj.jdbc.Driver - jpa: - hibernate: - ddl-auto: update - properties: - hibernate: - format_sql: false - show_sql: false - default_batch_fetch_size: 1000 - open-in-view: false - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB jwt: secret-key: ${JWT_SECRET_KEY} access-token-expired: ${ACCESS_TOKEN_EXPIRED} - refresh-token-expired: ${REFRESH_TOKEN_EXPIRED} - -openai: - secret-key: ${OPEN_AI_SECRET_KEY} - -storage: - aws: - access-key: ${S3_ACCESS_KEY} - secret-key: ${S3_SECRET_KEY} - region: ${S3_REGION} - bucket: ${S3_BUCKET} - host: ${CDN_HOST} - -kakao: - appKey: ${KAKAO_APP_KEY} - redirectUri: ${KAKAO_REDIRECT_URL} - -management: - endpoints: - web: - base-path: /api/actuator - exposure: - include: "prometheus" - -server: - tomcat: - mbeanregistry: - enabled: true - -logging: - level: - root: INFO \ No newline at end of file + refresh-token-expired: ${REFRESH_TOKEN_EXPIRED} \ No newline at end of file diff --git a/grida-core/core-api/src/test/kotlin/org/grida/docs/auth/AuthApiDocsTest.kt b/grida-core/core-api/src/test/kotlin/org/grida/docs/auth/AuthApiDocsTest.kt index 0de0ce81..290f6832 100644 --- a/grida-core/core-api/src/test/kotlin/org/grida/docs/auth/AuthApiDocsTest.kt +++ b/grida-core/core-api/src/test/kotlin/org/grida/docs/auth/AuthApiDocsTest.kt @@ -6,17 +6,10 @@ import io.wwan13.api.document.snippets.STRING import io.wwan13.api.document.snippets.isTypeOf import io.wwan13.api.document.snippets.moreAbout import io.wwan13.api.document.snippets.whichMeans -import io.wwan13.wintersecurity.jwt.TokenGenerator -import org.grida.auth.KakaoAuthClient -import org.grida.auth.KakaoAuthToken +import org.grida.auth.AuthProcessorSelector import org.grida.docs.ApiDocsTest -import org.grida.domain.user.LoginOption -import org.grida.domain.user.LoginPlatform -import org.grida.domain.user.User -import org.grida.domain.user.UserService +import org.grida.docs.auth.stub.StubAuthProcessor import org.grida.presentation.v1.auth.AuthController -import org.grida.user.KakaoUserClient -import org.grida.user.KakaoUserProfile import org.junit.jupiter.api.Test import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest @@ -29,42 +22,22 @@ class AuthApiDocsTest( ) { @MockkBean - private lateinit var userService: UserService - - @MockkBean - private lateinit var tokenGenerator: TokenGenerator - - @MockkBean - private lateinit var kakaoAuthClient: KakaoAuthClient - - @MockkBean - private lateinit var kakaoUserClient: KakaoUserClient + private lateinit var authProcessorSelector: AuthProcessorSelector @Test - fun `카카오 로그인 API`() { + fun `인증 토큰 발급 API`() { - val user = User( - id = 1L, name = "김태완", loginOption = LoginOption(LoginPlatform.KAKAO, "123123") - ) + every { authProcessorSelector.select(any()) } returns StubAuthProcessor() - every { userService.readUserByLoginOption(any()) } returns user - - every { tokenGenerator.accessToken(any()) } returns "accessToken" - every { tokenGenerator.refreshToken(any()) } returns "refreshToken" - - val kakaoAuthToken = KakaoAuthToken("kakaoAccessToken", "kakaoRefreshToken") - every { kakaoAuthClient.provideAuthToken(any()) } returns kakaoAuthToken - - val kakaoUserProfile = KakaoUserProfile("123123", "김태완") - every { kakaoUserClient.readUserProfile(any()) } returns kakaoUserProfile - - val api = api.get("/api/v1/auth/kakao") { + val api = api.get("/api/v1/auth") { + queryParam("platform", "oauth2 platform") queryParam("code", "kakao authorization code") } - documentFor(api, "kakao-login") { + documentFor(api, "provide-auth-token") { summary( - "카카오 로그인 API" moreAbout """ + "인증 토큰 발급 API" moreAbout """ + kakao
** local : https://kauth.kakao.com/oauth/authorize?client_id=e32f0cc35368a69966b54698b193a794& redirect_uri=http://localhost:8080/api/v1/auth/login/kakao&response_type=code
** live : https://kauth.kakao.com/oauth/authorize?client_id=e32f0cc35368a69966b54698b193a794& @@ -74,7 +47,10 @@ class AuthApiDocsTest( .map { it.trimEnd() } .joinToString("") ) - queryParameters("code" whichMeans "카카오 인증 토큰") + queryParameters( + "platform" whichMeans "oauth2 플랫폼 [kakao/**]", + "code" whichMeans "인증 토큰" + ) responseFields( "data.accessToken" isTypeOf STRING whichMeans "인증 토큰", "data.refreshToken" isTypeOf STRING whichMeans "재발급 토큰", diff --git a/grida-core/core-api/src/test/kotlin/org/grida/docs/auth/stub/StubAuthProcessor.kt b/grida-core/core-api/src/test/kotlin/org/grida/docs/auth/stub/StubAuthProcessor.kt new file mode 100644 index 00000000..6787bf8f --- /dev/null +++ b/grida-core/core-api/src/test/kotlin/org/grida/docs/auth/stub/StubAuthProcessor.kt @@ -0,0 +1,10 @@ +package org.grida.docs.auth.stub + +import org.grida.auth.AuthProcessor +import org.grida.auth.AuthToken + +class StubAuthProcessor : AuthProcessor { + override fun process(code: String): AuthToken { + return AuthToken("access token", "refresh token") + } +} diff --git a/grida-core/core-domain/build.gradle.kts b/grida-core/core-domain/build.gradle.kts index f96f9b02..1e60d7a8 100644 --- a/grida-core/core-domain/build.gradle.kts +++ b/grida-core/core-domain/build.gradle.kts @@ -2,5 +2,5 @@ dependencies { implementation("org.springframework:spring-tx:6.1.0") implementation(project(":grida-clients:openai-client")) - implementation(project(":grida-clients:storage-client")) + implementation(project(":grida-clients:s3-client")) } diff --git a/grida-core/core-domain/src/main/kotlin/org/grida/domain/base/BaseEnum.kt b/grida-core/core-domain/src/main/kotlin/org/grida/domain/base/ValueEnum.kt similarity index 54% rename from grida-core/core-domain/src/main/kotlin/org/grida/domain/base/BaseEnum.kt rename to grida-core/core-domain/src/main/kotlin/org/grida/domain/base/ValueEnum.kt index 71eb6ba6..977bac7a 100644 --- a/grida-core/core-domain/src/main/kotlin/org/grida/domain/base/BaseEnum.kt +++ b/grida-core/core-domain/src/main/kotlin/org/grida/domain/base/ValueEnum.kt @@ -3,15 +3,15 @@ package org.grida.domain.base import org.grida.error.GridaException import org.grida.error.InvalidEnumValue -interface BaseEnum> { +interface ValueEnum> { val value: String companion object { inline fun > resolve(value: String): T { val entries = enumValues() - return entries - .firstOrNull { (it as BaseEnum<*>).value == value } - ?: throw GridaException(InvalidEnumValue(enumValues())) + return enumValues() + .singleOrNull { (it as ValueEnum<*>).value == value } + ?: throw GridaException(InvalidEnumValue(entries.map { (it as ValueEnum<*>).value })) } } } diff --git a/grida-core/core-domain/src/main/kotlin/org/grida/domain/diary/DiaryScope.kt b/grida-core/core-domain/src/main/kotlin/org/grida/domain/diary/DiaryScope.kt index f09b4f4e..e737d6e5 100644 --- a/grida-core/core-domain/src/main/kotlin/org/grida/domain/diary/DiaryScope.kt +++ b/grida-core/core-domain/src/main/kotlin/org/grida/domain/diary/DiaryScope.kt @@ -1,5 +1,11 @@ package org.grida.domain.diary -enum class DiaryScope { - PUBLIC, FRIENDS_ONLY, PRIVATE +import org.grida.domain.base.ValueEnum + +enum class DiaryScope( + override val value: String +) : ValueEnum { + PUBLIC("공개"), + FRIENDS_ONLY("친구 공개"), + PRIVATE("비공개"); } diff --git a/grida-core/core-domain/src/main/kotlin/org/grida/domain/image/ImageStatus.kt b/grida-core/core-domain/src/main/kotlin/org/grida/domain/image/ImageStatus.kt index 5a173f24..2bcd2d66 100644 --- a/grida-core/core-domain/src/main/kotlin/org/grida/domain/image/ImageStatus.kt +++ b/grida-core/core-domain/src/main/kotlin/org/grida/domain/image/ImageStatus.kt @@ -1,5 +1,10 @@ package org.grida.domain.image -enum class ImageStatus { - ACTIVATE, DEACTIVATE +import org.grida.domain.base.ValueEnum + +enum class ImageStatus( + override val value: String +) : ValueEnum { + ACTIVATE("활성화"), + DEACTIVATE("비활성화"); } diff --git a/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/LoginPlatform.kt b/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/LoginPlatform.kt index 22c35854..e2efa927 100644 --- a/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/LoginPlatform.kt +++ b/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/LoginPlatform.kt @@ -1,11 +1,10 @@ package org.grida.domain.user -import org.grida.domain.base.BaseEnum +import org.grida.domain.base.ValueEnum enum class LoginPlatform( override val value: String -) : BaseEnum { - KAKAO("카카오"), - GOOGLE("구글"), - GITHUB("깃허브"); +) : ValueEnum { + KAKAO("kakao"), + ADMIN("admin") } diff --git a/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/UserService.kt b/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/UserService.kt index 786b8ccc..4590ec12 100644 --- a/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/UserService.kt +++ b/grida-core/core-domain/src/main/kotlin/org/grida/domain/user/UserService.kt @@ -30,6 +30,10 @@ class UserService( return userAppender.appendAndReturnUser(user) } + fun read(id: Long): User { + return userReader.read(id) + } + fun readUserByLoginOption( loginOption: LoginOption ): User? { diff --git a/grida-core/core-domain/src/main/kotlin/org/grida/error/CoreDomainErrorType.kt b/grida-core/core-domain/src/main/kotlin/org/grida/error/CoreDomainErrorType.kt index 90e91a53..127d3f6d 100644 --- a/grida-core/core-domain/src/main/kotlin/org/grida/error/CoreDomainErrorType.kt +++ b/grida-core/core-domain/src/main/kotlin/org/grida/error/CoreDomainErrorType.kt @@ -16,12 +16,13 @@ data class NoSuchData( override val logLevel: LogLevel = INFO } -class InvalidEnumValue( - enumValues: Array +class InvalidEnumValue( + enumValues: List ) : CoreDomainErrorType { override val httpStatusCode: Int = BAD_REQUEST override val errorCode: String = "CORE_DOMAIN_400_2" - override val message: String = "유효하지 않은 enum value 입니다.(${enumValues.joinToString(",")}})" + override val message: String = + "유효하지 않은 enum value 입니다.[${enumValues.joinToString("|")}]" override val logLevel: LogLevel = INFO } diff --git a/grida-core/core-domain/src/main/resources/application.properties b/grida-core/core-domain/src/main/resources/application-core-domain.properties similarity index 100% rename from grida-core/core-domain/src/main/resources/application.properties rename to grida-core/core-domain/src/main/resources/application-core-domain.properties diff --git a/grida-database/database-rds/src/main/resources/application-database-rds.yml b/grida-database/database-rds/src/main/resources/application-database-rds.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/grida-database/database-rds/build.gradle.kts b/grida-storage/rds-storage/build.gradle.kts similarity index 100% rename from grida-database/database-rds/build.gradle.kts rename to grida-storage/rds-storage/build.gradle.kts diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/config/DatabaseRdsConfig.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/config/RdsStorageConfig.kt similarity index 95% rename from grida-database/database-rds/src/main/kotlin/org/grida/config/DatabaseRdsConfig.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/config/RdsStorageConfig.kt index 037b0739..ccae74fb 100644 --- a/grida-database/database-rds/src/main/kotlin/org/grida/config/DatabaseRdsConfig.kt +++ b/grida-storage/rds-storage/src/main/kotlin/org/grida/config/RdsStorageConfig.kt @@ -11,4 +11,4 @@ import org.springframework.transaction.annotation.EnableTransactionManagement @EnableJpaAuditing @EntityScan(basePackages = ["org.grida"]) @EnableJpaRepositories(basePackages = ["org.grida"]) -class DatabaseRdsConfig +class RdsStorageConfig diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/base/BaseEntity.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/base/BaseEntity.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/base/BaseEntity.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/base/BaseEntity.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryEntity.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryEntity.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryEntity.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryEntity.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryEntityMapper.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryEntityMapper.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryEntityMapper.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryEntityMapper.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryEntityRepository.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryJpaEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryJpaEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diary/DiaryJpaEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diary/DiaryJpaEntityRepository.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntity.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntity.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntity.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntity.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityMapper.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityMapper.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityMapper.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityMapper.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageEntityRepository.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageJpaEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageJpaEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageJpaEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/diaryimage/DiaryImageJpaEntityRepository.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntity.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntity.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntity.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntity.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityMapper.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityMapper.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityMapper.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityMapper.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageEntityRepository.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageJpaEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageJpaEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageJpaEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/profileimage/ProfileImageJpaEntityRepository.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserEntity.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserEntity.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserEntity.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserEntity.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserEntityMapper.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserEntityMapper.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserEntityMapper.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserEntityMapper.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserEntityRepository.kt diff --git a/grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserJpaEntityRepository.kt b/grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserJpaEntityRepository.kt similarity index 100% rename from grida-database/database-rds/src/main/kotlin/org/grida/persistence/user/UserJpaEntityRepository.kt rename to grida-storage/rds-storage/src/main/kotlin/org/grida/persistence/user/UserJpaEntityRepository.kt diff --git a/grida-storage/rds-storage/src/main/resources/application-rds-storage.yml b/grida-storage/rds-storage/src/main/resources/application-rds-storage.yml new file mode 100644 index 00000000..d82893ad --- /dev/null +++ b/grida-storage/rds-storage/src/main/resources/application-rds-storage.yml @@ -0,0 +1,39 @@ +--- +spring: + config: + activate: + on-profile: dev + datasource: + url: jdbc:mysql://localhost:3306/grida?useSSL=false&allowPublicKeyRetrieval=true + username: root + password: + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + hibernate: + ddl-auto: update + properties: + hibernate: + format_sql: true + show_sql: true + default_batch_fetch_size: 1000 + open-in-view: false + +--- +spring: + config: + activate: + on-profile: prod + datasource: + url: ${DATASOURCE_URL} + username: ${DATABASE_USERNAME} + password: ${DATABASE_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + hibernate: + ddl-auto: update + properties: + hibernate: + format_sql: false + show_sql: false + default_batch_fetch_size: 1000 + open-in-view: false \ No newline at end of file diff --git a/grida-support/logging/build.gradle.kts b/grida-support/logging/build.gradle.kts new file mode 100644 index 00000000..7d82dc72 --- /dev/null +++ b/grida-support/logging/build.gradle.kts @@ -0,0 +1,2 @@ +dependencies { +} diff --git a/grida-support/logging/src/main/resources/application-logging.yml b/grida-support/logging/src/main/resources/application-logging.yml new file mode 100644 index 00000000..1ddb6f13 --- /dev/null +++ b/grida-support/logging/src/main/resources/application-logging.yml @@ -0,0 +1,2 @@ +logging: + config: classpath:logback/logback-${spring.profiles.active}.xml \ No newline at end of file diff --git a/grida-core/core-api/src/main/resources/logback.xml b/grida-support/logging/src/main/resources/logback/logback-dev.xml similarity index 85% rename from grida-core/core-api/src/main/resources/logback.xml rename to grida-support/logging/src/main/resources/logback/logback-dev.xml index 0a82d4e9..a37b1522 100644 --- a/grida-core/core-api/src/main/resources/logback.xml +++ b/grida-support/logging/src/main/resources/logback/logback-dev.xml @@ -2,7 +2,7 @@ - + @@ -18,12 +18,11 @@ ${LOG_PATH}/%d{yyyy-MM, aux}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}.log - 20GB - + diff --git a/grida-support/logging/src/main/resources/logback/logback-prod.xml b/grida-support/logging/src/main/resources/logback/logback-prod.xml new file mode 100644 index 00000000..a37b1522 --- /dev/null +++ b/grida-support/logging/src/main/resources/logback/logback-prod.xml @@ -0,0 +1,29 @@ + + + + + + + + + + ${LOG_PATTERN} + + + + + ${LOG_PATH}/${LOG_FILE_NAME}.log + + ${LOG_PATTERN} + + + ${LOG_PATH}/%d{yyyy-MM, aux}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}.log + 20GB + + + + + + + + \ No newline at end of file diff --git a/grida-support/monitoring/build.gradle.kts b/grida-support/monitoring/build.gradle.kts new file mode 100644 index 00000000..a69587dd --- /dev/null +++ b/grida-support/monitoring/build.gradle.kts @@ -0,0 +1,5 @@ +dependencies { + // monitoring + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("io.micrometer:micrometer-registry-prometheus") +} diff --git a/grida-support/monitoring/src/main/resources/application-monitoring.yml b/grida-support/monitoring/src/main/resources/application-monitoring.yml new file mode 100644 index 00000000..f25616a9 --- /dev/null +++ b/grida-support/monitoring/src/main/resources/application-monitoring.yml @@ -0,0 +1,11 @@ +management: + endpoints: + web: + base-path: /api/actuator + exposure: + include: "prometheus" + +server: + tomcat: + mbeanregistry: + enabled: true \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 7abec8fb..584af92a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,7 @@ rootProject.name = "grida" include("grida-clients") -include("grida-clients:storage-client") +include("grida-clients:s3-client") include("grida-clients:openai-client") include("grida-clients:kakao-client") @@ -9,7 +9,11 @@ include("grida-core") include("grida-core:core-api") include("grida-core:core-domain") -include("grida-database") -include("grida-database:database-rds") +include("grida-storage") +include("grida-storage:rds-storage") + +include("grida-support") +include("grida-support:monitoring") +include("grida-support:logging") include("grida-common")