Skip to content

Commit 4a45be6

Browse files
committed
feat: add endpoint to check app version
Add a new API endpoint that returns the current application version Signed-off-by: Omar <omar.brbutovic@secomind.com>
1 parent cedf748 commit 4a45be6

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file is part of Edgehog.
2+
#
3+
# Copyright 2026 SECO Mind Srl
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
19+
defmodule EdgehogWeb.VersionController do
20+
use EdgehogWeb, :controller
21+
22+
@version Mix.Project.config()[:version]
23+
24+
def show(conn, _params) do
25+
json(conn, %{version: @version})
26+
end
27+
end

backend/lib/edgehog_web/router.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ defmodule EdgehogWeb.Router do
5454
interface: :playground,
5555
socket: EdgehogWeb.GqlSocket
5656

57+
get "/version", EdgehogWeb.VersionController, :show
58+
5759
scope "/tenants/:tenant_slug" do
5860
scope "/api" do
5961
pipe_through :api
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file is part of Edgehog.
2+
#
3+
# Copyright 2026 SECO Mind Srl
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
19+
defmodule EdgehogWeb.Controllers.VersionControllerTest do
20+
use EdgehogWeb.ConnCase, async: true
21+
22+
@version Mix.Project.config()[:version]
23+
24+
test "returns the application version", %{conn: conn} do
25+
conn = get(conn, "/version")
26+
27+
assert %{"version" => version} = json_response(conn, 200)
28+
assert version == @version
29+
end
30+
end

0 commit comments

Comments
 (0)