diff --git a/src/main/java/tigerworkshop/webapphardwarebridge/Server.java b/src/main/java/tigerworkshop/webapphardwarebridge/Server.java index f00f970..4990132 100644 --- a/src/main/java/tigerworkshop/webapphardwarebridge/Server.java +++ b/src/main/java/tigerworkshop/webapphardwarebridge/Server.java @@ -1,6 +1,7 @@ package tigerworkshop.webapphardwarebridge; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fazecast.jSerialComm.SerialPort; import io.javalin.Javalin; @@ -10,10 +11,7 @@ import io.javalin.util.JavalinBindException; import io.javalin.websocket.WsContext; import lombok.extern.log4j.Log4j2; -import tigerworkshop.webapphardwarebridge.dtos.Config; -import tigerworkshop.webapphardwarebridge.dtos.NotificationDTO; -import tigerworkshop.webapphardwarebridge.dtos.PrintServiceDTO; -import tigerworkshop.webapphardwarebridge.dtos.SerialPortDTO; +import tigerworkshop.webapphardwarebridge.dtos.*; import tigerworkshop.webapphardwarebridge.interfaces.WebSocketServerInterface; import tigerworkshop.webapphardwarebridge.interfaces.WebSocketServiceInterface; import tigerworkshop.webapphardwarebridge.services.ConfigService; @@ -229,6 +227,12 @@ synchronized public void start() throws Exception { ctx.contentType(ContentType.APPLICATION_JSON).result(objectMapper.writeValueAsString(dtos)); }); + javalinServer.get("/system/version.json", ctx -> { + VersionDTO dto = new VersionDTO(Constants.APP_NAME, Constants.APP_ID, Constants.VERSION); + + ctx.contentType(ContentType.APPLICATION_JSON).result(objectMapper.writeValueAsString(dto)); + }); + javalinServer.post("/system/restart.json", ctx -> { stop(); ThreadUtil.silentSleep(500); @@ -239,6 +243,7 @@ synchronized public void start() throws Exception { try { javalinServer.start(serverConfig.getBind(), serverConfig.getPort()); + log.info("{} {} running on {}", Constants.APP_NAME, Constants.VERSION, serverConfig.getUri()); } catch (JavalinBindException e) { log.info("Unable to bind port, another instance is already running?"); System.exit(1); diff --git a/src/main/java/tigerworkshop/webapphardwarebridge/dtos/VersionDTO.java b/src/main/java/tigerworkshop/webapphardwarebridge/dtos/VersionDTO.java new file mode 100644 index 0000000..8859cda --- /dev/null +++ b/src/main/java/tigerworkshop/webapphardwarebridge/dtos/VersionDTO.java @@ -0,0 +1,12 @@ +package tigerworkshop.webapphardwarebridge.dtos; + +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +public class VersionDTO { + public String appName; + public String appId; + public String version; +}