From c2a192d4996eadd85e2a7b6ce80b0d94cca193f4 Mon Sep 17 00:00:00 2001 From: sophiathedev Date: Sun, 7 Dec 2025 16:33:12 +0700 Subject: [PATCH] feat(api): new api logic for OPTIONS /version this api will be the health check api, with the success health check will be return the application version and the runtime version --- .../controllers/version_controller.ex | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/blogservice_web/controllers/version_controller.ex b/lib/blogservice_web/controllers/version_controller.ex index 2243454..dfd423b 100644 --- a/lib/blogservice_web/controllers/version_controller.ex +++ b/lib/blogservice_web/controllers/version_controller.ex @@ -2,18 +2,19 @@ defmodule BlogserviceWeb.VersionController do use BlogserviceWeb, :controller def version(conn, _params) do - runtime_elixir = Application.spec(:elixir, :vsn) |> List.to_string() - runtime_application = Application.spec(:blogservice, :vsn) |> List.to_string() + runtime_elixir = Application.spec(:elixir, :vsn) + runtime_application = Application.spec(:blogservice, :vsn) + runtime_phoenix = Application.spec(:phoenix, :vsn) - # conn - # |> response(:ok, - # data: %{ - # runtime: %{ - # elixir: runtime_elixir, - # otp: runtime_application - # } - # } - # ) - conn |> response(:ok) + conn + |> response(:ok, + data: %{ + runtime: %{ + elixir: to_string(runtime_elixir), + phoenix: to_string(runtime_phoenix), + api: to_string(runtime_application) + } + } + ) end end