commit 4e54cc620a716f2366ae7031a223c0f49e4756db Author: Mysaa Java Date: Sun Aug 23 07:56:02 2026 +0200 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edcaaea --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# Flyway migration SQL +/db-migration.sql + +/result +/.gradle +/.vscode +/.postgres diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..9d1ae93 --- /dev/null +++ b/build.gradle @@ -0,0 +1,60 @@ +buildscript { + dependencies { + classpath 'org.flywaydb:flyway-database-postgresql:_' + classpath 'org.postgresql:postgresql:_' + } +} +plugins { + id 'java' + id 'org.flywaydb.flyway' version '13.3.0' + id 'org.springframework.boot' version '4.1.1' + id 'io.spring.dependency-management' version '1.1.7' +} + + +group = 'com.bernard' +version = '1.0' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +dependencies { + implementation Spring.boot.data.jpa + implementation Spring.boot.jdbc + implementation Spring.boot.thymeleaf + implementation Spring.boot.websocket + implementation Spring.boot.web + implementation 'org.springframework:spring-jdbc:_' + implementation 'org.flywaydb:flyway-core:_' + implementation 'org.flywaydb:flyway-database-postgresql:_' + implementation 'jakarta.validation:jakarta.validation-api:_' + runtimeOnly 'org.webjars:jquery:_' + runtimeOnly 'org.webjars:lodash:_' + developmentOnly Spring.boot.devTools + runtimeOnly 'org.postgresql:postgresql:_' + runtimeOnly 'org.hibernate.orm:hibernate-core:_' + testImplementation Spring.boot.test + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:_' + + //Lombok + compileOnly 'org.projectlombok:lombok:_' + annotationProcessor 'org.projectlombok:lombok:_' + + testCompileOnly 'org.projectlombok:lombok:_' + testAnnotationProcessor 'org.projectlombok:lombok:_' +} + +flyway { + url = "jdbc:postgresql://127.0.0.1:5432/nodecames" + user = 'nodecames' + password = 'nodecames-dev' + driver = 'org.postgresql.Driver' + schemas = ['nodecames'] +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c95466b --- /dev/null +++ b/flake.lock @@ -0,0 +1,100 @@ +{ + "nodes": { + "build-gradle-application": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems" + }, + "locked": { + "lastModified": 1778276441, + "narHash": "sha256-EcIds2qhx8XGnnqDYRHKgmZ/Sz5k8OGcta5inomRtE8=", + "ref": "refs/heads/main", + "rev": "3ffeebc94a4ba90850fa1afefa84f813c6c2078d", + "revCount": 123, + "type": "git", + "url": "file:/home/mysaa/Documents/Projets/buildGradleApplication" + }, + "original": { + "type": "git", + "url": "file:/home/mysaa/Documents/Projets/buildGradleApplication" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "build-gradle-application", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1777988971, + "narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1777954456, + "narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1787209939, + "narHash": "sha256-WvvHR4kSQLAbtouMC/ruZ5UpLwlUcY3K4FAllMN+yGk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "391b592eb44808b3bd0cb80bb71b63a5a118b8bb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "build-gradle-application": "build-gradle-application", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f7ca6d3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,81 @@ +{ + description = "Misael server"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + build-gradle-application.url = "git+file:/home/mysaa/Documents/Projets/buildGradleApplication";#"github:raphiz/buildGradleApplication"; + }; + + outputs = { self, nixpkgs, build-gradle-application, ... }@inputs: + let system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; overlays = [ build-gradle-application.overlays.default ]; }; + lib = pkgs.lib; + jdk = pkgs.openjdk21; + gradle = pkgs.gradle; + version = "1.0"; + + nodecames = pkgs.buildGradleArtifact { + pname = "nodecames"; + src = ./.; + buildTask = "bootJar"; + installPhase = '' + cp -r "build/libs/" "$out" + ''; + inherit version jdk gradle; + }; + + nodecames-launcher = pkgs.writeShellScriptBin "nodecames" '' + set -e + echo "Checking Database Migration" + ${pkgs.flyway}/bin/flyway "-url=$MISAEL_DATABASE" -user=nodecames "-password=$MISAEL_PASSWORD" -locations="filesystem:${nodecames}/resources/main/db/migration/" -schemas=nodecames migrate + + echo "Launching NodeCames" + ${jdk}/bin/java -jar ${nodecames}/nodecames-${version}.jar --spring.datasource.url=$MISAEL_DATABASE --spring.datasource.password=$MISAEL_PASSWORD "$@" + ''; + postgres-server = pkgs.writeShellScriptBin "postgres-server" '' + mkdir -p .postgres + ${pkgs.podman}/bin/podman run -e POSTGRES_USER=nodecames -e POSTGRES_PASSWORD=nodecames-dev -e POSTGRES_DB=nodecames --volume ./.postgres:/var/lib/postgresql -p 127.0.0.1:5432:5432 postgres:18.4 &> .postgres/postgres.log & + ''; + in { + packages.${system} = { + default = self.packages.${system}.nodecames; + inherit nodecames; + }; + + apps.${system} = { + default = self.apps.${system}.nodecames; + nodecames = { type = "app"; program = "${nodecames-launcher}/bin/nodecames"; }; + postgres-server = { type = "app"; program = "${postgres-server}/bin/postgres-server"; }; + }; + + devShells.${system} = { + default = pkgs.mkShell { + packages = [ + jdk + gradle + (pkgs.vscode-with-extensions.override { + vscode = pkgs.vscodium; + vscodeExtensions = with pkgs.vscode-extensions; [ + redhat.java + vscjava.vscode-java-debug + vscjava.vscode-java-test + vscjava.vscode-gradle + vscjava.vscode-java-dependency + sonarsource.sonarlint-vscode + bbenoist.nix + redhat.vscode-yaml + ]; + }) + ]; + shellHook = '' + echo "Starting Gradle daemon ..." + gradle + echo "Gradle daemon started." + ''; + }; + }; + + formatter.${system} = pkgs.nixpkgs-fmt; + }; +} diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml new file mode 100644 index 0000000..fcaf524 --- /dev/null +++ b/gradle/verification-metadata.xml @@ -0,0 +1,2340 @@ + + + + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..bbefb83 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,11 @@ +plugins { + id 'de.fayard.refreshVersions' version '0.60.6' +} +dependencyResolutionManagement { + repositories { + mavenCentral() + } + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) +} + +rootProject.name = 'nodecames' diff --git a/src/main/java/com/bernard/nodecames/HttpController.java b/src/main/java/com/bernard/nodecames/HttpController.java new file mode 100644 index 0000000..926d9b8 --- /dev/null +++ b/src/main/java/com/bernard/nodecames/HttpController.java @@ -0,0 +1,13 @@ +package com.bernard.nodecames; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class HttpController { + + @GetMapping("/") + public String index() { + return "index.html"; + } +} diff --git a/src/main/java/com/bernard/nodecames/NodecamesApplication.java b/src/main/java/com/bernard/nodecames/NodecamesApplication.java new file mode 100644 index 0000000..32a769a --- /dev/null +++ b/src/main/java/com/bernard/nodecames/NodecamesApplication.java @@ -0,0 +1,13 @@ +package com.bernard.nodecames; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class NodecamesApplication { + + public static void main(String[] args) { + SpringApplication.run(NodecamesApplication.class, args); + } + +} diff --git a/src/main/java/com/bernard/nodecames/ThymeleafConfig.java b/src/main/java/com/bernard/nodecames/ThymeleafConfig.java new file mode 100644 index 0000000..792773d --- /dev/null +++ b/src/main/java/com/bernard/nodecames/ThymeleafConfig.java @@ -0,0 +1,23 @@ +package com.bernard.nodecames; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; +import org.springframework.web.socket.WebSocketHandler; + +import com.bernard.nodecames.frontend.GameWebSocketHandler; + +@Configuration +public class ThymeleafConfig { + + @Bean + public HandlerMapping webSocketHandler() { + Map map = new HashMap<>(); + map.put("/path", new GameWebSocketHandler()); + return new SimpleUrlHandlerMapping(map, -1); + } +} \ No newline at end of file diff --git a/src/main/java/com/bernard/nodecames/frontend/GameWebSocketHandler.java b/src/main/java/com/bernard/nodecames/frontend/GameWebSocketHandler.java new file mode 100644 index 0000000..fbc866b --- /dev/null +++ b/src/main/java/com/bernard/nodecames/frontend/GameWebSocketHandler.java @@ -0,0 +1,39 @@ +package com.bernard.nodecames.frontend; + +import org.springframework.web.socket.CloseStatus; +import org.springframework.web.socket.WebSocketHandler; +import org.springframework.web.socket.WebSocketMessage; +import org.springframework.web.socket.WebSocketSession; + +public class GameWebSocketHandler implements WebSocketHandler { + + @Override + public void handleMessage(WebSocketSession session, WebSocketMessage message) throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public void afterConnectionEstablished(WebSocketSession session) throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public boolean supportsPartialMessages() { + // TODO Auto-generated method stub + return false; + } +} diff --git a/src/main/java/com/bernard/nodecames/model/Game.java b/src/main/java/com/bernard/nodecames/model/Game.java new file mode 100644 index 0000000..7ed58e5 --- /dev/null +++ b/src/main/java/com/bernard/nodecames/model/Game.java @@ -0,0 +1,20 @@ +package com.bernard.nodecames.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +@Entity +@NoArgsConstructor +@AllArgsConstructor +public class Game { + + @Id + @GeneratedValue + private Long id; + + private String name; + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..03df8e5 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,39 @@ +spring: + datasource: + url: jdbc:postgresql://127.0.0.1:5432/nodecames + username: nodecames + password: nodecames-dev + driver-class-name: org.postgresql.Driver + hikari: + schema: nodecames + flyway: + enabled: true + locations: classpath:db/migration/structure, classpath:db/migration/data + validate-on-migrate: true + default-schema: nodecames + create-schemas: true + session: + jdbc: + initialize-schema: always + security: + user: + name: mysaa + + jpa: + properties: + javax: + persistence: + schema-generation: + create-source: metadata + scripts: + action: update + create-target: db-migration.sql + database: + action: none + hibernate: + ddl-auto: none + generate-ddl: true + +logging: + level: + root: INFO \ No newline at end of file diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css new file mode 100644 index 0000000..d83738f --- /dev/null +++ b/src/main/resources/static/css/style.css @@ -0,0 +1,17 @@ +@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap'); +*{ + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: 'Poppins', sans-serif; +} +main{ + display: flex; + width: 100%; + align-items: center; + justify-content: center; + color: #3d7091; + font-size: 24px; + flex-direction: column; + margin-top: 115px; +} \ No newline at end of file diff --git a/src/main/resources/templates/html-head.html b/src/main/resources/templates/html-head.html new file mode 100644 index 0000000..499b1dd --- /dev/null +++ b/src/main/resources/templates/html-head.html @@ -0,0 +1,6 @@ + +NodeCames + + + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..6c87eb9 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,12 @@ + + + +
+ + + +
+ Vous voulez jouer à Node Cames ? Ben c'est pas encore prêt :/ +
+ + \ No newline at end of file diff --git a/src/test/java/com/bernard/nodecames/NodeCamesApplicationTests.java b/src/test/java/com/bernard/nodecames/NodeCamesApplicationTests.java new file mode 100644 index 0000000..1ed67ab --- /dev/null +++ b/src/test/java/com/bernard/nodecames/NodeCamesApplicationTests.java @@ -0,0 +1,8 @@ +package com.bernard.nodecames; + +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class NodeCamesApplicationTests { + +} diff --git a/versions.properties b/versions.properties new file mode 100644 index 0000000..06110f9 --- /dev/null +++ b/versions.properties @@ -0,0 +1,42 @@ +#### Dependencies and Plugin versions with their available updates. +#### Generated by `./gradlew refreshVersions` version 0.60.6 +#### +#### Don't manually edit or split the comments that start with four hashtags (####), +#### they will be overwritten by refreshVersions. +#### +#### suppress inspection "SpellCheckingInspection" for whole file +#### suppress inspection "UnusedProperty" for whole file + +version.com.fasterxml.jackson.core..jackson-databind=2.22.2 + +version.com.fasterxml.jackson.datatype..jackson-datatype-hibernate5=2.22.2 + +version.jakarta.validation..jakarta.validation-api=3.1.1 +## # available=4.0.0-M1 + +version.jakarta.websocket..jakarta.websocket-api=2.2.0 +## # available=2.3.0-M1 +## # available=2.3.0-M2 + +version.org.flywaydb..flyway-core=13.3.0 + +version.org.flywaydb..flyway-database-postgresql=13.3.0 + +version.org.hibernate.orm..hibernate-core=7.4.6.Final +## # available=8.0.0.Alpha1 +## # available=8.0.0.Beta1 + +version.org.junit.platform..junit-platform-launcher=6.1.3 + +version.org.postgresql..postgresql=42.7.13 + +version.org.projectlombok..lombok=1.18.46 + +version.org.springframework..spring-jdbc=7.0.9 +## # available=7.1.0-M1 + +version.org.thymeleaf.extras..thymeleaf-extras-springsecurity6=3.1.5.RELEASE + +version.org.webjars..jquery=4.0.0 + +version.org.webjars..lodash=4.17.21