Refactor API structure and enhance logging/debugging.

Modularized OpenAPI definitions by splitting into dedicated files for teams, bans, and errors. Improved backend logging for database connections, CORS configuration, and debugging. Updated application properties to support environment-specific CORS origins and logging levels.
This commit is contained in:
2025-04-10 21:45:00 +02:00
parent 23f298b8c9
commit 2137459e9b
10 changed files with 138 additions and 100 deletions
@@ -13,12 +13,9 @@ public class CorsConfig implements WebMvcConfigurer {
@Value("${cors.allowed-origins}")
private String[] allowedOrigins;
public CorsConfig() {
log.info("test");
}
@Override
public void addCorsMappings(CorsRegistry registry) {
log.info("Registering CORS mappings for {}", String.join(", ", allowedOrigins));
registry.addMapping("/**")
.allowedOrigins(allowedOrigins)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
@@ -25,7 +25,7 @@ public class TeamApiController implements TeamApi {
Connection.getConnection(Databases.LUCK_PERMS, configuration -> configuration.addMapper(TeamMemberMapper.class))
.thenApply(connection -> {
connection.runQuery(sqlSession -> {
log.info("Loading team members for group {}", group);
log.debug("Loading team members for group {}", group);
List<Player> players = sqlSession.getMapper(TeamMemberMapper.class).getTeamMembers("group." + group);
playerGroupFuture.complete(players);
});
@@ -0,0 +1,8 @@
spring.application.name=AltitudeWeb
database.name=${DB_NAME:web_db}
database.port=${DB_PORT:3306}
database.host=${DB_HOST:localhost}
database.user=${DB_USER:root}
database.password=${DB_PASSWORD:root}
cors.allowed-origins=${CORS:http://localhost:4200}
logging.level.com.alttd.altitudeweb=DEBUG
@@ -4,4 +4,5 @@ database.port=${DB_PORT:3306}
database.host=${DB_HOST:localhost}
database.user=${DB_USER:root}
database.password=${DB_PASSWORD:root}
cors.allowed-origins=${CORS:http://localhost:4200}
cors.allowed-origins=${CORS:https://alttd.com}
logging.level.com.alttd.altitudeweb=INFO