From a2c1e11f56f29de4143f67fd5f128572edb0e50e Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Thu, 6 Jun 2024 12:54:20 -0400 Subject: [PATCH] API Proj --- API/.gitignore | 29 +++++++++ API/README.md | 2 + API/pom.xml | 60 +++++++++++++++++++ .../me/braydon/profanity/TextPurifyAPI.java | 36 +++++++++++ .../profanity/service/FiltrationService.java | 12 ++++ .../profanity/service/ModerationService.java | 12 ++++ API/src/main/resources/application.yml | 19 ++++++ API/src/main/resources/banner.txt | 12 ++++ 8 files changed, 182 insertions(+) create mode 100644 API/.gitignore create mode 100644 API/README.md create mode 100644 API/pom.xml create mode 100644 API/src/main/java/me/braydon/profanity/TextPurifyAPI.java create mode 100644 API/src/main/java/me/braydon/profanity/service/FiltrationService.java create mode 100644 API/src/main/java/me/braydon/profanity/service/ModerationService.java create mode 100644 API/src/main/resources/application.yml create mode 100644 API/src/main/resources/banner.txt diff --git a/API/.gitignore b/API/.gitignore new file mode 100644 index 0000000..80ab21c --- /dev/null +++ b/API/.gitignore @@ -0,0 +1,29 @@ +*.class +*.log +*.ctxt +.mtj.tmp/ +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar +hs_err_pid* +replay_pid* +.idea +cmake-build-*/ +.idea/**/mongoSettings.xml +*.iws +out/ +build/ +work/ +target/ +.idea_modules/ +atlassian-ide-plugin.xml +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +git.properties +pom.xml.versionsBackup \ No newline at end of file diff --git a/API/README.md b/API/README.md new file mode 100644 index 0000000..2d6fe1f --- /dev/null +++ b/API/README.md @@ -0,0 +1,2 @@ +# API +The backend API for TextPurify, responsible for the filtering and moderation of text content. The API is built using Springboot, a modern Java web framework. The API can be accessed [here](https://purify.rainnny.club). \ No newline at end of file diff --git a/API/pom.xml b/API/pom.xml new file mode 100644 index 0000000..76ae134 --- /dev/null +++ b/API/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.0 + + + + + me.braydon + TextPurify-API + 1.0.0 + + + + 17 + UTF-8 + + + + + ${project.artifactId} + + + + org.springframework.boot + spring-boot-maven-plugin + + + build-info + + build-info + + + + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.projectlombok + lombok + 1.18.32 + provided + + + \ No newline at end of file diff --git a/API/src/main/java/me/braydon/profanity/TextPurifyAPI.java b/API/src/main/java/me/braydon/profanity/TextPurifyAPI.java new file mode 100644 index 0000000..c20ed3d --- /dev/null +++ b/API/src/main/java/me/braydon/profanity/TextPurifyAPI.java @@ -0,0 +1,36 @@ +package me.braydon.profanity; + +import lombok.NonNull; +import lombok.SneakyThrows; +import lombok.extern.log4j.Log4j2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.Objects; + +/** + * @author Braydon + */ +@SpringBootApplication +@Log4j2(topic = "TextPurify") +public class TextPurifyAPI { + @SneakyThrows + public static void main(@NonNull String[] args) { + // Handle loading of our configuration file + File config = new File("application.yml"); + if (!config.exists()) { // Saving the default config if it doesn't exist locally + Files.copy(Objects.requireNonNull(TextPurifyAPI.class.getResourceAsStream("/application.yml")), config.toPath(), StandardCopyOption.REPLACE_EXISTING); + log.info("Saved the default configuration to '{}', please re-launch the application", // Log the default config being saved + config.getAbsolutePath() + ); + return; + } + log.info("Found configuration at '{}'", config.getAbsolutePath()); // Log the found config + + // Start the app + SpringApplication.run(TextPurifyAPI.class, args); + } +} \ No newline at end of file diff --git a/API/src/main/java/me/braydon/profanity/service/FiltrationService.java b/API/src/main/java/me/braydon/profanity/service/FiltrationService.java new file mode 100644 index 0000000..d983608 --- /dev/null +++ b/API/src/main/java/me/braydon/profanity/service/FiltrationService.java @@ -0,0 +1,12 @@ +package me.braydon.profanity.service; + +import org.springframework.stereotype.Service; + +/** + * This service is responsible + * for filtering text content. + * + * @author Braydon + */ +@Service +public final class FiltrationService { } \ No newline at end of file diff --git a/API/src/main/java/me/braydon/profanity/service/ModerationService.java b/API/src/main/java/me/braydon/profanity/service/ModerationService.java new file mode 100644 index 0000000..77d4d00 --- /dev/null +++ b/API/src/main/java/me/braydon/profanity/service/ModerationService.java @@ -0,0 +1,12 @@ +package me.braydon.profanity.service; + +import org.springframework.stereotype.Service; + +/** + * This service is responsible for moderating text + * content and reporting it to the appropriate parties. + * + * @author Braydon + */ +@Service +public final class ModerationService { } \ No newline at end of file diff --git a/API/src/main/resources/application.yml b/API/src/main/resources/application.yml new file mode 100644 index 0000000..263ff6d --- /dev/null +++ b/API/src/main/resources/application.yml @@ -0,0 +1,19 @@ +# Server Configuration +server: + address: 0.0.0.0 + port: 7500 + +# Log Configuration +logging: + file: + path: "./logs" + +# Spring Configuration +spring: + # Don't serialize null values by default with Jackson + jackson: + default-property-inclusion: non_null + + # Ignore + banner: + location: "classpath:banner.txt" \ No newline at end of file diff --git a/API/src/main/resources/banner.txt b/API/src/main/resources/banner.txt new file mode 100644 index 0000000..dca66eb --- /dev/null +++ b/API/src/main/resources/banner.txt @@ -0,0 +1,12 @@ + _______ _ _____ _ __ _____ _____ + |__ __| | | | __ \ (_)/ _| /\ | __ \_ _| + | | _____ _| |_| |__) | _ _ __ _| |_ _ _ / \ | |__) || | + | |/ _ \ \/ / __| ___/ | | | '__| | _| | | | / /\ \ | ___/ | | + | | __/> <| |_| | | |_| | | | | | | |_| | / ____ \| | _| |_ + |_|\___/_/\_\\__|_| \__,_|_| |_|_| \__, | /_/ \_\_| |_____| + __/ | + |___/ + + | API Version - v${application.version} + | Spring Version - ${spring-boot.formatted-version} +____________________________________________________________________________ \ No newline at end of file