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
217 changes: 217 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.flima</groupId>
<artifactId>portfolio-flima-dev</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>quarkus</packaging>

<properties>
<compiler-plugin.version>3.15.0</compiler-plugin.version>
<maven.compiler.release>25</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.34.5</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.5.4</surefire-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-camel-bom</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.mapstruct</groupId>
<artifactId>quarkus-mapstruct</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>com.password4j</groupId>
<artifactId>password4j</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-jwt-build</artifactId>
<version>3.35.0</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mailer</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-jwt</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-smallrye-reactive-messaging</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kafka-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-messaging-kafka</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-flyway</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.bucket4j</groupId>
<artifactId>quarkus-bucket4j</artifactId>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jacoco</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-security</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-kafka-companion</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<argLine>@{argLine}</argLine>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<argLine>@{argLine}</argLine>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.jar.enabled>false</quarkus.package.jar.enabled>
<skipITs>false</skipITs>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dev.flima.presentation.rest.auth;

import dev.flima.application.auth.dtos.request.LoginDTORequest;
import dev.flima.application.auth.dtos.response.LoginDTOResponse;
import dev.flima.application.auth.usecases.LoginUseCase;
import jakarta.validation.Valid;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

@Path("/auth")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class AuthResource {

private final LoginUseCase loginUseCase;

public AuthResource(LoginUseCase loginUseCase) {
this.loginUseCase = loginUseCase;
}

@POST
public Response login(@Valid LoginDTORequest loginDTO) {
LoginDTOResponse response = loginUseCase.execute(loginDTO);
return Response.status(Response.Status.ACCEPTED).entity(response).build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package dev.flima.presentation.rest.contents;

import dev.flima.application.contents.dtos.request.ContentDTORequest;
import dev.flima.application.contents.dtos.response.ContentDTOResponse;
import dev.flima.application.contents.dtos.response.CreateContentDTOResponse;
import dev.flima.application.contents.usecases.*;
import dev.flima.domain.users.Role;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.validation.Valid;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import java.util.List;
import java.util.UUID;

@Path("/contents")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@RolesAllowed({Role.Labels.OWNER})
public class ContentResource {

private final CreateContentUseCase createContentUseCase;
private final UpdateContentUseCase updateContentUseCase;
private final DeleteContentUseCase deleteContentUseCase;
private final GetContentUseCase getContentUseCase;
private final GetAllContentUseCase getAllContentUseCase;

public ContentResource(
CreateContentUseCase createContentUseCase,
UpdateContentUseCase updateContentUseCase,
DeleteContentUseCase deleteContentUseCase,
GetContentUseCase getContentUseCase,
GetAllContentUseCase getAllContentUseCase
) {
this.createContentUseCase = createContentUseCase;
this.updateContentUseCase = updateContentUseCase;
this.deleteContentUseCase = deleteContentUseCase;
this.getContentUseCase = getContentUseCase;
this.getAllContentUseCase = getAllContentUseCase;
}

@POST
public Response create(@Valid ContentDTORequest contentDTORequest) {
CreateContentDTOResponse response = createContentUseCase.execute(contentDTORequest);
return Response.status(Response.Status.CREATED).entity(response).build();
}

@PUT
@Path("/{id}")
public Response update(@Valid @PathParam("id") UUID id, ContentDTORequest contentDTORequest) {
ContentDTOResponse response = updateContentUseCase.execute(id, contentDTORequest);
return Response.status(Response.Status.OK).entity(response).build();
}

@GET
@Path("/{id}")
public Response getById(@PathParam("id") UUID id) {
ContentDTOResponse response = getContentUseCase.execute(id);
return Response.status(Response.Status.OK).entity(response).build();
}

@GET
@PermitAll
public Response getAll() {
List<ContentDTOResponse> response = getAllContentUseCase.execute();
return Response.status(Response.Status.OK).entity(response).build();
}

@DELETE
@Path("/{id}")
public Response delete(@PathParam("id") UUID id) {
deleteContentUseCase.execute(id);
return Response.status(Response.Status.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.flima.presentation.rest.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import java.time.LocalDateTime;
import java.util.List;

public record ErrorResponse(
String message,
int status,
LocalDateTime timestamp,

@JsonInclude(JsonInclude.Include.NON_NULL)
List<String> details
) {
public ErrorResponse {
if (timestamp == null) {
timestamp = LocalDateTime.now();
}
}

public static ErrorResponse of(String message, int status) {
return new ErrorResponse(message, status, LocalDateTime.now(), null);
}

public static ErrorResponse of(String message, int status, List<String> details) {
return new ErrorResponse(message, status, LocalDateTime.now(), details);
}
}
Loading