diff --git a/backend/src/main/java/com/alttd/altitudeweb/controllers/CorsConfig.java b/backend/src/main/java/com/alttd/altitudeweb/controllers/CorsConfig.java index 6f9feea..421f901 100644 --- a/backend/src/main/java/com/alttd/altitudeweb/controllers/CorsConfig.java +++ b/backend/src/main/java/com/alttd/altitudeweb/controllers/CorsConfig.java @@ -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") diff --git a/backend/src/main/java/com/alttd/altitudeweb/controllers/TeamApiController.java b/backend/src/main/java/com/alttd/altitudeweb/controllers/TeamApiController.java index 4c1b7c4..20d9820 100644 --- a/backend/src/main/java/com/alttd/altitudeweb/controllers/TeamApiController.java +++ b/backend/src/main/java/com/alttd/altitudeweb/controllers/TeamApiController.java @@ -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 players = sqlSession.getMapper(TeamMemberMapper.class).getTeamMembers("group." + group); playerGroupFuture.complete(players); }); diff --git a/backend/src/main/resources/application-test.properties b/backend/src/main/resources/application-test.properties new file mode 100644 index 0000000..4ef76f0 --- /dev/null +++ b/backend/src/main/resources/application-test.properties @@ -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 diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 64d14c8..6af4629 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -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 diff --git a/database/src/main/java/com/alttd/altitudeweb/database/Connection.java b/database/src/main/java/com/alttd/altitudeweb/database/Connection.java index 184dd1d..4f2b012 100644 --- a/database/src/main/java/com/alttd/altitudeweb/database/Connection.java +++ b/database/src/main/java/com/alttd/altitudeweb/database/Connection.java @@ -42,16 +42,20 @@ public class Connection { } CompletableFuture settingsFuture = new CompletableFuture<>(); getConnection(Databases.DEFAULT, (mapper -> mapper.addMapper(SettingsMapper.class))).thenApply(connection -> { + log.debug("Loading settings for database {}", database.getInternalName()); connection.runQuery(session -> { + log.debug("Running query to load settings for database"); DatabaseSettings loadedSettings = session.getMapper(SettingsMapper.class).getSettings(database.getInternalName()); if (loadedSettings == null) { log.error("Failed to load settings for database {}", database.getInternalName()); } + log.debug("Loaded settings {}", loadedSettings); settingsFuture.complete(loadedSettings); }); return null; }); return settingsFuture.thenApply(loadedSettings -> { + log.debug("Storing connection for database {}", database.getInternalName()); Connection connection = new Connection(loadedSettings, addMappers); connections.put(database, connection); return connection; @@ -66,7 +70,9 @@ public class Connection { System.getenv("DB_USER"), System.getenv("DB_PASS") ); + log.debug("Loaded default database settings {}", databaseSettings); Connection connection = new Connection(databaseSettings, addMappers); + log.debug("Created default database connection {}", connection); return CompletableFuture.completedFuture(connection); } diff --git a/frontend/src/app/team/team.component.ts b/frontend/src/app/team/team.component.ts index 4203e83..9803bfd 100644 --- a/frontend/src/app/team/team.component.ts +++ b/frontend/src/app/team/team.component.ts @@ -1,10 +1,12 @@ import {Component} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; -import {BASE_PATH, Player, TeamService} from '../../api'; +import {BASE_PATH} from '../../api'; import {CommonModule, NgOptimizedImage} from '@angular/common'; import {HeaderComponent} from '../header/header.component'; import {CookieService} from 'ngx-cookie-service'; import {map, Observable, shareReplay} from 'rxjs'; +import {TeamService} from '../../api/api/team.service'; +import {Player} from '../../api/model/player'; @Component({ selector: 'app-team', diff --git a/open_api/src/main/resources/api.yml b/open_api/src/main/resources/api.yml index e9ea756..6d41d52 100644 --- a/open_api/src/main/resources/api.yml +++ b/open_api/src/main/resources/api.yml @@ -10,96 +10,7 @@ tags: - name: player description: Retrieve player information paths: - /player/teamMembers/{group}: - get: - tags: - - team - summary: Get team members - description: Retrieve players who are part of the specified team - operationId: getTeamMembers - parameters: - - name: group - in: path - required: true - description: The group name of the team - schema: - type: string - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/TeamMembers' - default: - description: Unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /player/history: - post: - tags: - - user - summary: Get player history - description: Retrieves all types of player history about the player - operationId: getPlayerHistory - requestBody: - description: The player history - content: - application/json: - schema: - $ref: '#/components/schemas/Player' - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/PlayerHistory' - default: - description: Unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" -components: - schemas: - PlayerHistory: - type: object - properties: - punishmentType: - type: string - punishment: - type: string - active: - type: boolean - start: - type: integer - format: int64 - duration: - type: integer - format: int64 - TeamMembers: - type: array - items: - $ref: '#/components/schemas/Player' - Player: - type: object - properties: - name: - type: string - description: The name of the player - example: a_name - uuid: - type: string - example: 0c35e520-927e-4c6a-87ad-ff0739c22e9d - description: The uuid of the team player - required: - - name - - uuid - Error: - type: object - properties: - reason: - type: string + /team: + $ref: './sub_api/team/team.yml' + /history: + $ref: './sub_api/bans/bans.yml' diff --git a/open_api/src/main/resources/sub_api/bans/bans.yml b/open_api/src/main/resources/sub_api/bans/bans.yml new file mode 100644 index 0000000..e4c75b6 --- /dev/null +++ b/open_api/src/main/resources/sub_api/bans/bans.yml @@ -0,0 +1,58 @@ +paths: + /history: + post: + tags: + - user + summary: Get player history + description: Retrieves all types of player history about the player + operationId: getPlayerHistory + requestBody: + description: The player history + content: + application/json: + schema: + $ref: '#/components/schemas/Player' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/PlayerHistory' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "../generic/errors.yml#/components/schemas/Error" +components: + schemas: + PlayerHistory: + type: object + properties: + punishmentType: + type: string + punishment: + type: string + active: + type: boolean + start: + type: integer + format: int64 + duration: + type: integer + format: int64 + Player: + type: object + properties: + name: + type: string + description: The name of the player + example: a_name + uuid: + type: string + example: 0c35e520-927e-4c6a-87ad-ff0739c22e9d + description: The uuid of the team player + required: + - name + - uuid diff --git a/open_api/src/main/resources/sub_api/generic/errors.yml b/open_api/src/main/resources/sub_api/generic/errors.yml new file mode 100644 index 0000000..6a999af --- /dev/null +++ b/open_api/src/main/resources/sub_api/generic/errors.yml @@ -0,0 +1,7 @@ +components: + schemas: + Error: + type: object + properties: + reason: + type: string diff --git a/open_api/src/main/resources/sub_api/team/team.yml b/open_api/src/main/resources/sub_api/team/team.yml new file mode 100644 index 0000000..0f67d93 --- /dev/null +++ b/open_api/src/main/resources/sub_api/team/team.yml @@ -0,0 +1,48 @@ +paths: + /{group}: + get: + tags: + - team + summary: Get team members + description: Retrieve players who are part of the specified team + operationId: getTeamMembers + parameters: + - name: group + in: path + required: true + description: The group name of the team + schema: + type: string + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/TeamMembers' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "../generic/errors.yml#/components/schemas/Error" +components: + schemas: + TeamMembers: + type: array + items: + $ref: '#/components/schemas/Player' + Player: + type: object + properties: + name: + type: string + description: The name of the player + example: a_name + uuid: + type: string + example: 0c35e520-927e-4c6a-87ad-ff0739c22e9d + description: The uuid of the team player + required: + - name + - uuid