Add a health endpoint

This commit is contained in:
Mike Cifelli 2024-03-18 16:12:41 -04:00
parent c214b3e7e3
commit 53f4bc5ecf
Signed by: mike
GPG Key ID: 6B08C6BE47D08E4C
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,7 @@
defmodule ChronoscopeWeb.API.V1.HealthController do
use ChronoscopeWeb, :controller
def get(conn, _params) do
json(conn, %{healthy: true})
end
end

View File

@ -20,6 +20,12 @@ defmodule ChronoscopeWeb.Router do
get "/", PageController, :home
end
scope "/api/v1", ChronoscopeWeb.API.V1 do
pipe_through :api
get "/health", HealthController, :get
end
scope "/api/v1/nts", ChronoscopeWeb.API.V1.NTS do
pipe_through :api

View File

@ -0,0 +1,12 @@
defmodule ChronoscopeWeb.API.V1.HealthControllerTest do
use ChronoscopeWeb.ConnCase, async: true
test "indicates health", %{conn: conn} do
response =
conn
|> get(~p"/api/v1/health")
|> json_response(200)
assert %{"healthy" => true} == response
end
end