Skip to content

Commit

Permalink
chore():refacto to microservices
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaut-Mouton committed Nov 8, 2024
1 parent 27a4334 commit d3fd5e0
Show file tree
Hide file tree
Showing 222 changed files with 1,266 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-back.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
distribution: 'temurin'
cache: maven
- name: build
run: mvn -Dmaven.test.skip=true compile -f backend/pom.xml
run: mvn -Dmaven.test.skip=true compile -f backend/core/pom.xml
95 changes: 95 additions & 0 deletions backend/cache/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?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>
<artifactId>messenger</artifactId>
<groupId>com.mercure</groupId>
<version>1.3.0</version>
</parent>

<groupId>com.mercure</groupId>
<artifactId>cache</artifactId>
<version>1.0-SNAPSHOT</version>

<name>cache</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<!-- Optionally: parameterized tests support -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
10 changes: 10 additions & 0 deletions backend/cache/src/main/java/com/mercure/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.mercure;

/**
* Hello world!
*/
public class App {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
19 changes: 19 additions & 0 deletions backend/cache/src/test/java/com/mercure/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.mercure;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

/**
* Unit test for simple App.
*/
public class AppTest {

/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue() {
assertTrue(true);
}
}
Binary file added backend/cache/target/cache-1.0-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
Binary file added backend/cache/target/classes/com/mercure/App.class
Binary file not shown.
3 changes: 3 additions & 0 deletions backend/cache/target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifactId=cache
groupId=com.mercure
version=1.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com/mercure/App.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/IdeaProjects/react-spring-messenger-project/backend/cache/src/main/java/com/mercure/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com/mercure/AppTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/IdeaProjects/react-spring-messenger-project/backend/cache/src/test/java/com/mercure/AppTest.java
Binary file not shown.
110 changes: 110 additions & 0 deletions backend/core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?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>
<artifactId>messenger</artifactId>
<groupId>com.mercure</groupId>
<version>1.3.0</version>
</parent>

<groupId>com.mercure</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>

<name>core</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<!-- Optionally: parameterized tests support -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
Expand All @@ -20,12 +20,11 @@
import java.io.IOException;

@Component
@AllArgsConstructor
public class JwtWebConfig extends OncePerRequestFilter {

@Autowired
private CustomUserDetailsService userDetailsService;

@Autowired
private JwtUtil jwtUtil;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mercure.config;

import com.mercure.service.CustomUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
Expand All @@ -17,13 +18,13 @@
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

@Configuration
@AllArgsConstructor
@NoArgsConstructor
public class SecurityConfig {

@Autowired
public JwtWebConfig jwtWebConfig;
private JwtWebConfig jwtWebConfig;

@Autowired
public CustomUserDetailsService customUserDetailsService;
private CustomUserDetailsService customUserDetailsService;

@Bean
public PasswordEncoder passwordEncoder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
import com.mercure.utils.StaticVariable;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.WebUtils;
Expand All @@ -27,23 +26,18 @@

@RestController
@CrossOrigin(allowCredentials = "true", origins = "http://localhost:3000")
@AllArgsConstructor
@Slf4j
public class ApiController {

private final Logger log = LoggerFactory.getLogger(ApiController.class);

@Autowired
private UserService userService;

@Autowired
private GroupService groupService;

@Autowired
private GroupMapper groupMapper;

@Autowired
private GroupUserJoinService groupUserJoinService;

@Autowired
private JwtUtil jwtUtil;

@GetMapping(value = "/users/all/{groupUrl}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand All @@ -32,29 +31,22 @@

@RestController
@CrossOrigin(allowCredentials = "true", origins = "http://localhost:3000", methods = {RequestMethod.GET, RequestMethod.POST})
@AllArgsConstructor
@Slf4j
public class AuthenticationController {

private final Logger log = LoggerFactory.getLogger(AuthenticationController.class);

@Autowired
private JwtUtil jwtTokenUtil;

@Autowired
private CustomUserDetailsService userDetailsService;

@Autowired
private UserMapper userMapper;

@Autowired
private UserService userService;

@Autowired
private GroupService groupService;

@Autowired
private GroupMapper groupMapper;

@Autowired
private AuthenticationManager authenticationManager;

@PostMapping(value = "/auth")
Expand Down
Loading

0 comments on commit d3fd5e0

Please sign in to comment.