From 652ee81fb0300b4a3fb3f29b3780031464f409a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:33:02 +0000 Subject: [PATCH 1/4] Bump io.javalin:javalin from 5.6.3 to 6.3.0 in /server Bumps [io.javalin:javalin](https://github.com/javalin/javalin) from 5.6.3 to 6.3.0. - [Release notes](https://github.com/javalin/javalin/releases) - [Commits](https://github.com/javalin/javalin/compare/javalin-parent-5.6.3...javalin-parent-6.3.0) --- updated-dependencies: - dependency-name: io.javalin:javalin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- server/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/build.gradle b/server/build.gradle index faf03d4..f8c9d62 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -29,7 +29,7 @@ repositories { // External dependencies that our application utilizes dependencies { // Javalin, a simple web framework for Java - implementation 'io.javalin:javalin:5.6.3' + implementation 'io.javalin:javalin:6.3.0' // Jackson, a JSON library for Java implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2' From 56c39b771d8aacfa16e0888fe5597628fa79af9b Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Thu, 29 Aug 2024 13:42:35 -0500 Subject: [PATCH 2/4] Move from Java17 to Java21 Java v21 is the most recent Long Term Support (LTS) version, so it makes sense to bump up to it. --- server/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/build.gradle b/server/build.gradle index f8c9d62..3ac4ccc 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -12,10 +12,10 @@ plugins { id 'checkstyle' } -// Build and run the project with Java 17 +// Build and run the project with Java 21 java { toolchain { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(21) } } From 6f29af84f5d822d2411ec7d365f16aa648cbfbe1 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Thu, 29 Aug 2024 13:43:28 -0500 Subject: [PATCH 3/4] Convert to new Javalin plugin syntax This updates our code to match the new Javalin syntax for adding plugins to a server. --- server/src/main/java/umm3601/Server.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/main/java/umm3601/Server.java b/server/src/main/java/umm3601/Server.java index 2c2b6eb..c5506db 100644 --- a/server/src/main/java/umm3601/Server.java +++ b/server/src/main/java/umm3601/Server.java @@ -5,7 +5,6 @@ import io.javalin.Javalin; import io.javalin.http.InternalServerErrorResponse; import io.javalin.http.staticfiles.Location; -import io.javalin.plugin.bundled.RouteOverviewPlugin; public class Server { @@ -78,7 +77,7 @@ private Javalin configureJavalin() { // This adds a Javalin plugin that will list all of the // routes/endpoints that we add below on a page reachable // via the "/api" path. - config.plugins.register(new RouteOverviewPlugin("/api")); + config.bundledPlugins.enableRouteOverview("/api"); }); // This catches any uncaught exceptions thrown in the server From 4125819a8f67cdc07d55f619c629002eac860bc9 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Thu, 29 Aug 2024 13:45:06 -0500 Subject: [PATCH 4/4] Add `User::toString()` This adds a simple `toString()` method to the `User` class to help with debugging. --- server/src/main/java/umm3601/user/User.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/src/main/java/umm3601/user/User.java b/server/src/main/java/umm3601/user/User.java index 7c63a00..8fe3e64 100644 --- a/server/src/main/java/umm3601/user/User.java +++ b/server/src/main/java/umm3601/user/User.java @@ -26,4 +26,18 @@ public class User { public int age; public String company; public String email; + + // Having some kind of `toString()` allows us to print `User`s, + // which can be useful/necessary in error handling. This only + // returns the name, but it could be extended to return more or + // all of the fields combined into a single string. + // + // The other option would be to return `_id`, but that can be + // `null` if we're trying to add a new `User` to the database + // that doesn't yet have an `_id`, so returning `name` seemed + // the better bet. + @Override + public String toString() { + return name; + } }