starting request service
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
12
.run/Testing.run.xml
Normal file
12
.run/Testing.run.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Testing" type="JUnit" factoryName="JUnit">
|
||||||
|
<module name="website" />
|
||||||
|
<option name="PACKAGE_NAME" value="dev.mars3142" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
|
<option name="METHOD_NAME" value="" />
|
||||||
|
<option name="TEST_OBJECT" value="package" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
31
pom.xml
31
pom.xml
@@ -14,6 +14,7 @@
|
|||||||
<vaadin.version>24.4.0.beta4</vaadin.version>
|
<vaadin.version>24.4.0.beta4</vaadin.version>
|
||||||
<spring-cloud.version>2023.0.1</spring-cloud.version>
|
<spring-cloud.version>2023.0.1</spring-cloud.version>
|
||||||
<spring-cloud-gcp.version>5.4.1</spring-cloud-gcp.version>
|
<spring-cloud-gcp.version>5.4.1</spring-cloud-gcp.version>
|
||||||
|
<spring-modulith.version>1.1.6</spring-modulith.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@@ -72,6 +73,13 @@
|
|||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.modulith</groupId>
|
||||||
|
<artifactId>spring-modulith-bom</artifactId>
|
||||||
|
<version>${spring-modulith.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@@ -110,10 +118,6 @@
|
|||||||
<groupId>com.google.cloud</groupId>
|
<groupId>com.google.cloud</groupId>
|
||||||
<artifactId>spring-cloud-gcp-starter</artifactId>
|
<artifactId>spring-cloud-gcp-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
@@ -123,6 +127,25 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.modulith</groupId>
|
||||||
|
<artifactId>spring-modulith-starter-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.modulith</groupId>
|
||||||
|
<artifactId>spring-modulith-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.modulith</groupId>
|
||||||
|
<artifactId>spring-modulith-actuator</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.modulith</groupId>
|
||||||
|
<artifactId>spring-modulith-observability</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account;
|
||||||
|
|
||||||
|
public interface AccountService{
|
||||||
|
}
|
@@ -0,0 +1,17 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories;
|
||||||
|
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.LoginResponse;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.AccountDeleteResponse;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.AccountRegisterResponse;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.RefreshTokenResponse;
|
||||||
|
|
||||||
|
public interface AccountRepository {
|
||||||
|
|
||||||
|
AccountRegisterResponse register(String username, String email, String password);
|
||||||
|
|
||||||
|
LoginResponse login(String username, String password);
|
||||||
|
|
||||||
|
RefreshTokenResponse refreshToken(String token);
|
||||||
|
|
||||||
|
AccountDeleteResponse delete(String token);
|
||||||
|
}
|
@@ -0,0 +1,68 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl;
|
||||||
|
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.AccountRegisterResponse;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.LoginResponse;
|
||||||
|
import dev.mars3142.fhq.account.repositories.AccountRepository;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.requests.AccountDeleteRequest;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.requests.LoginRequest;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.requests.RefreshTokenRequest;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.AccountDeleteResponse;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.responses.RefreshTokenResponse;
|
||||||
|
import dev.mars3142.fhq.account.repositories.impl.requests.AccountRegisterRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import lombok.val;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.web.client.RestClient;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class AccountRepositoryImpl implements AccountRepository {
|
||||||
|
|
||||||
|
private final RestClient client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AccountRegisterResponse register(String username, String email, String password) {
|
||||||
|
val request = new AccountRegisterRequest(username, email, password);
|
||||||
|
return client
|
||||||
|
.post()
|
||||||
|
.uri("/v1/account/register")
|
||||||
|
.body(request)
|
||||||
|
.retrieve()
|
||||||
|
.body(AccountRegisterResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoginResponse login(String email, String password) {
|
||||||
|
val request = new LoginRequest(email, password);
|
||||||
|
return client
|
||||||
|
.post()
|
||||||
|
.uri("/v1/account/login")
|
||||||
|
.body(request)
|
||||||
|
.retrieve()
|
||||||
|
.body(LoginResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RefreshTokenResponse refreshToken(String token) {
|
||||||
|
val request = new RefreshTokenRequest(token);
|
||||||
|
return client
|
||||||
|
.post()
|
||||||
|
.uri("/v1/account/refresh")
|
||||||
|
.body(request)
|
||||||
|
.retrieve()
|
||||||
|
.body(RefreshTokenResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AccountDeleteResponse delete(String token) {
|
||||||
|
val request = new AccountDeleteRequest(token);
|
||||||
|
return client
|
||||||
|
.post()
|
||||||
|
.uri("/v1/account/delete")
|
||||||
|
.body(request)
|
||||||
|
.retrieve()
|
||||||
|
.body(AccountDeleteResponse.class);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||||
|
|
||||||
|
public record AccountDeleteRequest(String token) {
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||||
|
|
||||||
|
public record AccountRegisterRequest(String username, String email, String password) {
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||||
|
|
||||||
|
public record LoginRequest(String email, String password) {
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||||
|
|
||||||
|
public record RefreshTokenRequest(String token) {
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||||
|
|
||||||
|
public record AccountDeleteResponse() {
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||||
|
|
||||||
|
public record AccountRegisterResponse() {
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||||
|
|
||||||
|
public record LoginResponse() {
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||||
|
|
||||||
|
public record RefreshTokenResponse() {
|
||||||
|
}
|
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.mars3142.fhq.account.services;
|
||||||
|
|
||||||
|
import dev.mars3142.fhq.account.repositories.AccountRepository;
|
||||||
|
import dev.mars3142.fhq.account.AccountService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AccountServiceImpl implements AccountService {
|
||||||
|
|
||||||
|
private final AccountRepository repository;
|
||||||
|
|
||||||
|
}
|
18
src/main/java/dev/mars3142/fhq/config/AppConfig.java
Normal file
18
src/main/java/dev/mars3142/fhq/config/AppConfig.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package dev.mars3142.fhq.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.client.RestClient;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class AppConfig {
|
||||||
|
|
||||||
|
@Value("${backend.uri}")
|
||||||
|
private String baseUri;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestClient restClient() {
|
||||||
|
return RestClient.builder().baseUrl(baseUri).build();
|
||||||
|
}
|
||||||
|
}
|
@@ -26,8 +26,8 @@ import com.vaadin.flow.theme.lumo.LumoUtility.Padding;
|
|||||||
import com.vaadin.flow.theme.lumo.LumoUtility.TextColor;
|
import com.vaadin.flow.theme.lumo.LumoUtility.TextColor;
|
||||||
import com.vaadin.flow.theme.lumo.LumoUtility.Whitespace;
|
import com.vaadin.flow.theme.lumo.LumoUtility.Whitespace;
|
||||||
import com.vaadin.flow.theme.lumo.LumoUtility.Width;
|
import com.vaadin.flow.theme.lumo.LumoUtility.Width;
|
||||||
import dev.mars3142.fhq.views.checkoutform.CheckoutFormView;
|
import dev.mars3142.fhq.views.checkout_form.CheckoutFormView;
|
||||||
import dev.mars3142.fhq.views.myview.MyViewView;
|
import dev.mars3142.fhq.views.my_view.MyViewView;
|
||||||
import org.vaadin.lineawesome.LineAwesomeIcon;
|
import org.vaadin.lineawesome.LineAwesomeIcon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package dev.mars3142.fhq.views.checkoutform;
|
package dev.mars3142.fhq.views.checkout_form;
|
||||||
|
|
||||||
import com.vaadin.flow.component.Component;
|
import com.vaadin.flow.component.Component;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
@@ -1,4 +1,4 @@
|
|||||||
package dev.mars3142.fhq.views.landingpage;
|
package dev.mars3142.fhq.views.landing_page;
|
||||||
|
|
||||||
import com.vaadin.flow.component.applayout.AppLayout;
|
import com.vaadin.flow.component.applayout.AppLayout;
|
||||||
import com.vaadin.flow.component.html.Div;
|
import com.vaadin.flow.component.html.Div;
|
@@ -0,0 +1,17 @@
|
|||||||
|
package dev.mars3142.fhq.views.landing_page;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.Composite;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
|
import com.vaadin.flow.router.PageTitle;
|
||||||
|
import com.vaadin.flow.router.Route;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@PageTitle("Firmware HQ")
|
||||||
|
@Route(value = "", layout = LandingPageLayout.class)
|
||||||
|
@Slf4j
|
||||||
|
public class LandingPageView extends Composite<VerticalLayout> {
|
||||||
|
|
||||||
|
public LandingPageView() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -1,26 +0,0 @@
|
|||||||
package dev.mars3142.fhq.views.landingpage;
|
|
||||||
|
|
||||||
import com.vaadin.flow.component.Composite;
|
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
|
||||||
import com.vaadin.flow.router.PageTitle;
|
|
||||||
import com.vaadin.flow.router.Route;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import lombok.val;
|
|
||||||
import org.springframework.web.client.RestClient;
|
|
||||||
|
|
||||||
@PageTitle("Firmware HQ")
|
|
||||||
@Route(value = "", layout = LandingPageLayout.class)
|
|
||||||
@Slf4j
|
|
||||||
public class LandingPageView extends Composite<VerticalLayout> {
|
|
||||||
public LandingPageView() {
|
|
||||||
val client = RestClient
|
|
||||||
.builder()
|
|
||||||
.baseUrl("https://user-service-ggxookssmq-ew.a.run.app/v1")
|
|
||||||
.build();
|
|
||||||
val response = client.get()
|
|
||||||
.uri("/users")
|
|
||||||
.retrieve()
|
|
||||||
.body(String.class);
|
|
||||||
log.info("Response: {}", response);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
package dev.mars3142.fhq.views.myview;
|
package dev.mars3142.fhq.views.my_view;
|
||||||
|
|
||||||
import com.vaadin.flow.component.Composite;
|
import com.vaadin.flow.component.Composite;
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
@@ -5,3 +5,6 @@ vaadin:
|
|||||||
# To improve the performance during development.
|
# To improve the performance during development.
|
||||||
# For more information https://vaadin.com/docs/latest/integrations/spring/configuration#special-configuration-parameters
|
# For more information https://vaadin.com/docs/latest/integrations/spring/configuration#special-configuration-parameters
|
||||||
allowed-packages : com.vaadin,org.vaadin,dev.hilla,dev.mars3142
|
allowed-packages : com.vaadin,org.vaadin,dev.hilla,dev.mars3142
|
||||||
|
|
||||||
|
backend:
|
||||||
|
uri: http://localhost:8091/v1
|
||||||
|
@@ -10,3 +10,6 @@ spring:
|
|||||||
check-template-location: false
|
check-template-location: false
|
||||||
jpa:
|
jpa:
|
||||||
defer-datasource-initialization: true
|
defer-datasource-initialization: true
|
||||||
|
|
||||||
|
backend:
|
||||||
|
uri: https://api.firmware-hq.dev/v1
|
||||||
|
35
src/test/java/dev/mars3142/fhq/ApplicationTest.java
Normal file
35
src/test/java/dev/mars3142/fhq/ApplicationTest.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package dev.mars3142.fhq;
|
||||||
|
|
||||||
|
import lombok.val;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.modulith.core.ApplicationModules;
|
||||||
|
import org.springframework.modulith.docs.Documenter;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class ApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void modules() {
|
||||||
|
ApplicationModules.of(Application.class).forEach(System.out::println);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void verify() {
|
||||||
|
ApplicationModules.of(Application.class).verify();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void documentation() {
|
||||||
|
val modules = ApplicationModules.of(Application.class);
|
||||||
|
|
||||||
|
new Documenter(modules)
|
||||||
|
.writeDocumentation()
|
||||||
|
.writeModuleCanvases()
|
||||||
|
.writeModulesAsPlantUml();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user