Skip to content
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
@@ -1,7 +1,7 @@
FROM eclipse-temurin:17-jdk-jammy AS build
WORKDIR /app

COPY gradlew settings.gradle.kts build.gradle.kts ./
COPY gradlew settings.gradle build.gradle ./
COPY gradle ./gradle
RUN chmod +x ./gradlew && ./gradlew --no-daemon help

Expand Down
117 changes: 117 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.5'
id 'io.spring.dependency-management' version '1.1.6'
id 'com.diffplug.spotless' version '6.25.0'
id 'checkstyle'
}

group = 'org.bytefight'
version = '0.0.1'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
}

def springCloudGcpVersion = '5.0.0'
def springCloudVersion = '2023.0.0'
def jjwtVersion = '0.11.5'
def testcontainersVersion = '1.18.3'

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'net.logstash.logback:logstash-logback-encoder:8.0'
implementation 'com.github.loki4j:loki-logback-appender:1.4.1'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-amqp'

implementation 'com.github.luben:zstd-jni:1.5.6-9'

implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'

runtimeOnly 'org.postgresql:postgresql'
runtimeOnly 'com.h2database:h2'
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-database-postgresql'

implementation platform('com.google.cloud:libraries-bom:26.29.0')
implementation 'com.google.cloud:google-cloud-storage'

implementation platform('org.hibernate.search:hibernate-search-bom:7.0.1.Final')
implementation 'org.hibernate.search:hibernate-search-mapper-orm'
implementation 'org.hibernate.search:hibernate-search-backend-lucene'

implementation "io.jsonwebtoken:jjwt-api:${jjwtVersion}"
runtimeOnly "io.jsonwebtoken:jjwt-impl:${jjwtVersion}"
runtimeOnly "io.jsonwebtoken:jjwt-jackson:${jjwtVersion}"

implementation 'me.paulschwarz:spring-dotenv:3.0.0'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.13'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

developmentOnly 'org.springframework.boot:spring-boot-devtools'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

testImplementation 'org.springframework.boot:spring-boot-testcontainers:3.3.5'
testImplementation "org.testcontainers:junit-jupiter:${testcontainersVersion}"
testImplementation "org.testcontainers:postgresql:${testcontainersVersion}"
testImplementation "org.testcontainers:rabbitmq:${testcontainersVersion}"

testRuntimeOnly 'org.postgresql:postgresql'
}

dependencyManagement {
imports {
mavenBom "com.google.cloud:spring-cloud-gcp-dependencies:${springCloudGcpVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

tasks.withType(Test) {
useJUnitPlatform()
}

spotless {
java {
googleJavaFormat('1.17.0')

removeUnusedImports()

importOrder('', 'java', 'javax', 'org', 'com')

trimTrailingWhitespace()
endWithNewline()
}
}

checkstyle {
toolVersion = '10.17.0'
configDirectory = file("${rootDir}/config/checkstyle")
}

tasks.withType(Checkstyle) {
reports {
xml.required = true
html.required = true
}
}
116 changes: 0 additions & 116 deletions build.gradle.kts

This file was deleted.

54 changes: 0 additions & 54 deletions create_backup.sh

This file was deleted.

6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
depends_on:
postgres:
condition: service_healthy
loki:
condition: service_started
env_file:
- .env
ports:
Expand Down Expand Up @@ -54,6 +56,10 @@ services:
- grafana_data:/var/lib/grafana
restart: unless-stopped

loki:
image: grafana/loki:latest
command: -config.file=/etc/loki/local-config.yaml

volumes:
db_data:
driver: local
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'BotFightWebServer'
1 change: 0 additions & 1 deletion settings.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.LinkedHashMap;
import java.util.Map;

import lombok.extern.slf4j.Slf4j;

import org.bytefight.webserver.auth.domain.RegistrationException;
import org.bytefight.webserver.common.domain.PermissionDeniedException;
import org.springframework.http.HttpStatus;
Expand All @@ -15,6 +17,7 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
private ProblemDetail problem(HttpStatus status, String title, String detail) {
Expand All @@ -26,6 +29,7 @@ private ProblemDetail problem(HttpStatus status, String title, String detail) {

@ExceptionHandler(MethodArgumentNotValidException.class)
ProblemDetail handleValidation(MethodArgumentNotValidException ex) {
log.warn("Validation failed: {}", ex.getMessage());
ProblemDetail pd = ProblemDetail.forStatus(HttpStatus.BAD_REQUEST);
pd.setTitle("Validation Failed");
pd.setDetail("One or more fields are invalid.");
Expand All @@ -42,6 +46,7 @@ ProblemDetail handleValidation(MethodArgumentNotValidException ex) {
@ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ProblemDetail handleConstraintViolation(ConstraintViolationException ex) {
log.warn("Constraint violation: {}", ex.getMessage());
ProblemDetail pd = ProblemDetail.forStatus(HttpStatus.BAD_REQUEST);
pd.setTitle("Validation failed");

Expand All @@ -56,18 +61,21 @@ public ProblemDetail handleConstraintViolation(ConstraintViolationException ex)

@ExceptionHandler(RegistrationException.class)
ProblemDetail handleRegistration(RegistrationException ex) {
log.warn("Registration error: {}", ex.getMessage());
return problem(HttpStatus.CONFLICT, "Registration Error", ex.getMessage());
}

@ExceptionHandler(IllegalArgumentException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ProblemDetail handleIllegalArgument(IllegalArgumentException ex) {
log.warn("Illegal argument: {}", ex.getMessage());
return problem(HttpStatus.BAD_REQUEST, "Bad Request", ex.getMessage());
}

@ExceptionHandler(PermissionDeniedException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
ProblemDetail handlePermissionDenied(PermissionDeniedException ex) {
log.warn("Permission denied: {}", ex.getMessage());
return problem(HttpStatus.CONFLICT, "Permission Denied", ex.getMessage());
}
}
Loading
Loading