diff --git a/services/recom-backend/src/main/java/com/recom/api/HeartbeatController.java b/services/recom-backend/src/main/java/com/recom/api/HeartbeatController.java new file mode 100644 index 00000000..8a14caba --- /dev/null +++ b/services/recom-backend/src/main/java/com/recom/api/HeartbeatController.java @@ -0,0 +1,70 @@ +package com.recom.api; + +import com.recom.api.commons.HttpCommons; +import com.recom.dto.authentication.AccountRequestDto; +import com.recom.dto.authentication.AuthenticationRequestDto; +import com.recom.dto.authentication.AuthenticationResponseDto; +import com.recom.service.AuthenticationService; +import com.recom.service.ReforgerPayloadParserService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.CacheControl; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +@Slf4j +@Validated +@RestController +@RequiredArgsConstructor +@Tag(name = "Heartbeat") +@RequestMapping("/api/v1/heartbeat") +public class HeartbeatController { + + @Operation( + summary = "Heartbeat", + description = "Sends an is-alive message." + ) + @ApiResponses(value = { + @ApiResponse(responseCode = HttpCommons.OK_CODE, description = HttpCommons.OK), + @ApiResponse(responseCode = HttpCommons.UNAUTHORIZED_CODE, description = HttpCommons.UNAUTHORIZED, content = {@Content()}), + }) + @PostMapping(path = "/form", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) + public ResponseEntity heartbeatForm( + @RequestParam(required = true) + @NonNull final Map payload + ) { + log.debug("Requested POST /api/v1/authenticate (FORM)"); + + return heartbeatJSON(); + } + + @Operation( + summary = "Heartbeat", + description = "Sends an is-alive message." + ) + @ApiResponses(value = { + @ApiResponse(responseCode = HttpCommons.OK_CODE, description = HttpCommons.OK), + @ApiResponse(responseCode = HttpCommons.UNAUTHORIZED_CODE, description = HttpCommons.UNAUTHORIZED, content = {@Content()}), + }) + @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity heartbeatJSON() { + log.debug("Requested POST /api/v1/heartbeat (JSON)"); + + return ResponseEntity.status(HttpStatus.OK) + .cacheControl(CacheControl.noCache()) + .build(); + } + +} diff --git a/services/recom-backend/src/main/resources/application-local.properties b/services/recom-backend/src/main/resources/application-local.properties index 3315de99..9641e368 100644 --- a/services/recom-backend/src/main/resources/application-local.properties +++ b/services/recom-backend/src/main/resources/application-local.properties @@ -14,6 +14,8 @@ logging.level.com.recom.service.gameMap.TopographyMapDataService=INFO logging.level.com.recom.service.dbcached=INFO logging.level.com.recom.persistence.dbcached=DEBUG +logging.level.com.recom.api.AuthenticationController=DEBUG +logging.level.com.recom.api.HeartbeatController=DEBUG #logging.level.org.hibernate.SQL=DEBUG #logging.level.org.hibernate.com.jdbc.bind=TRACE logging.level.com.vladmihalcea.hibernate.type.util.LogUtils=DEBUG diff --git a/services/recom-backend/src/main/resources/application.properties b/services/recom-backend/src/main/resources/application.properties index 7fe40ca0..61fa2245 100644 --- a/services/recom-backend/src/main/resources/application.properties +++ b/services/recom-backend/src/main/resources/application.properties @@ -76,7 +76,7 @@ recom.ehcache-base-dir=${recom.data-base-dir}/ehcache recom.ehcache-appcache-base-dir=${recom.data-base-dir}/ehcache_appcache recom.security.jwt-issuer=RECOM DEV Backend -recom.security.jwt-expiration-time=60m +recom.security.jwt-expiration-time=60s recom.security.key-path=${recom.data-base-dir}/RECOMKey recom.async.core-pool-size=1