Remove Gateway service and configuration
- Delete Gateway module, associated Spring Boot application, and related configuration (`GatewayApplication.java`, `application.yml`, and `pom.xml`). - Remove Gateway references in `docker-compose.yml`, `.gitlab-ci.yml`, and `backend/pom.xml`. - Update backend services to directly handle requests under `/api` prefix (e.g., `/api/customers`, `/api/contact`). - Adjust frontend contact route to connect directly to the server, replacing gateway references with server URLs.
This commit is contained in:
@@ -1,21 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="GatewayApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
|
||||||
<option name="envFilePaths">
|
|
||||||
<option value="$PROJECT_DIR$/gateway.env" />
|
|
||||||
</option>
|
|
||||||
<module name="gateway" />
|
|
||||||
<selectedOptions>
|
|
||||||
<option name="environmentVariables" />
|
|
||||||
</selectedOptions>
|
|
||||||
<option name="SPRING_BOOT_MAIN_CLASS" value="dev.rheinsw.gateway.GatewayApplication" />
|
|
||||||
<extension name="coverage">
|
|
||||||
<pattern>
|
|
||||||
<option name="PATTERN" value="dev.rheinsw.gateway.*" />
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</pattern>
|
|
||||||
</extension>
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@@ -7,7 +7,6 @@ build_backend:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- backend/common/target/
|
- backend/common/target/
|
||||||
- backend/gateway/target/
|
|
||||||
- backend/discovery/target/
|
- backend/discovery/target/
|
||||||
- backend/server/target
|
- backend/server/target
|
||||||
expire_in: 1 hour
|
expire_in: 1 hour
|
||||||
@@ -21,18 +20,6 @@ docker_common:
|
|||||||
needs:
|
needs:
|
||||||
- build_backend
|
- build_backend
|
||||||
|
|
||||||
docker_gateway:
|
|
||||||
extends: .docker-build-template
|
|
||||||
variables:
|
|
||||||
IMAGE_NAME: gateway
|
|
||||||
COMMON_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/common"
|
|
||||||
WORKDIR_PATH: backend
|
|
||||||
DOCKERFILE_PATH: Dockerfile.app
|
|
||||||
BUILD_FOLDER: "gateway/target"
|
|
||||||
MAIN_CLASS: dev.rheinsw.gateway.GatewayApplication
|
|
||||||
needs:
|
|
||||||
- build_backend
|
|
||||||
- docker_common
|
|
||||||
|
|
||||||
docker_server:
|
docker_server:
|
||||||
extends: .docker-build-template
|
extends: .docker-build-template
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>dev.rheinsw</groupId>
|
|
||||||
<artifactId>backend</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<groupId>dev.rheinsw.backend</groupId>
|
|
||||||
<artifactId>gateway</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
|
||||||
<maven.compiler.target>21</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>${maven.compiler.plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${maven.compiler.source}</source>
|
|
||||||
<target>${maven.compiler.target}</target>
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
|
||||||
<version>3.6.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>copy-dependencies</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-dependencies</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
|
||||||
<includeScope>runtime</includeScope>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
|
||||||
<artifactId>caffeine</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Tools -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>dev.rheinsw</groupId>
|
|
||||||
<artifactId>common</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package dev.rheinsw.gateway;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Thatsaphorn Atchariyaphap
|
|
||||||
* @since 04.05.25
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class GatewayApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(GatewayApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
server:
|
|
||||||
port: 8080
|
|
||||||
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
name: gateway
|
|
||||||
main:
|
|
||||||
web-application-type: reactive # Set the application type to reactive
|
|
||||||
|
|
||||||
cloud:
|
|
||||||
gateway:
|
|
||||||
routes:
|
|
||||||
- id: server
|
|
||||||
uri: http://${SERVER_HOST:localhost}:8081
|
|
||||||
predicates:
|
|
||||||
- Path=/api/**
|
|
||||||
filters:
|
|
||||||
- StripPrefix=1
|
|
||||||
- PreserveHostHeader
|
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
<module>gateway</module>
|
|
||||||
<module>server</module>
|
<module>server</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RequestMapping("/contact")
|
@RequestMapping("/api/contact")
|
||||||
public class ContactController {
|
public class ContactController {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ContactController.class);
|
private static final Logger log = LoggerFactory.getLogger(ContactController.class);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.util.UUID;
|
|||||||
* @since 02.07.25
|
* @since 02.07.25
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/customers")
|
@RequestMapping("/api/customers")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CustomerController extends AbstractController {
|
public class CustomerController extends AbstractController {
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @since 04.05.25
|
* @since 04.05.25
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/mail")
|
@RequestMapping("/api/mail")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MailController {
|
public class MailController {
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.UUID;
|
|||||||
* @since 12.07.25
|
* @since 12.07.25
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/projects")
|
@RequestMapping("/api/projects")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ProjectController extends AbstractController {
|
public class ProjectController extends AbstractController {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
server:
|
server:
|
||||||
port: 8081
|
port: 8080
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|||||||
@@ -1,18 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
gateway:
|
|
||||||
image: registry.boomlab.party/rheinsw/rheinsw-mono-repo/gateway
|
|
||||||
container_name: gateway
|
|
||||||
env_file:
|
|
||||||
- ./gateway.env
|
|
||||||
restart: on-failure
|
|
||||||
networks:
|
|
||||||
- rheinsw-net
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
image: registry.boomlab.party/rheinsw/rheinsw-mono-repo/server
|
image: registry.boomlab.party/rheinsw/rheinsw-mono-repo/server
|
||||||
container_name: server
|
container_name: server
|
||||||
env_file:
|
env_file:
|
||||||
- ./server.env
|
- ./server.env
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
networks:
|
networks:
|
||||||
- rheinsw-net
|
- rheinsw-net
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import {NextRequest, NextResponse} from 'next/server'
|
|||||||
const HCAPTCHA_SECRET = process.env.HCAPTCHA_SECRET ?? ''
|
const HCAPTCHA_SECRET = process.env.HCAPTCHA_SECRET ?? ''
|
||||||
const SHARED_API_KEY = process.env.SHARED_API_KEY ?? ''
|
const SHARED_API_KEY = process.env.SHARED_API_KEY ?? ''
|
||||||
|
|
||||||
// Detect whether to use localhost or Docker gateway
|
// Detect whether to use localhost or Docker server
|
||||||
const useLocalGatewayEnv = process.env.USE_LOCAL_GATEWAY
|
const useLocalServerEnv = process.env.USE_LOCAL_SERVER
|
||||||
const useLocalGateway = useLocalGatewayEnv?.toLowerCase() === 'true'
|
const useLocalServer = useLocalServerEnv?.toLowerCase() === 'true'
|
||||||
const gatewayHost = useLocalGateway ? 'http://localhost:8080' : 'http://gateway:8080'
|
const serverHost = useLocalServer ? 'http://localhost:8080' : 'http://server:8080'
|
||||||
|
|
||||||
export async function POST(req: NextRequest) {
|
export async function POST(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
@@ -42,7 +42,7 @@ export async function POST(req: NextRequest) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Step 2: Forward to backend service
|
// Step 2: Forward to backend service
|
||||||
const backendRes = await fetch(`${gatewayHost}/api/contact`, {
|
const backendRes = await fetch(`${serverHost}/api/contact`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Origin: origin,
|
Origin: origin,
|
||||||
|
|||||||
Reference in New Issue
Block a user