Skip to content

Commit 96befa1

Browse files
committed
feat(version): new version public endpoint
GET api/public/v1/version
1 parent e88102a commit 96befa1

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

routes/public_api.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@
1717
use libs\utils\CacheRegions;
1818
// public api ( without AUTHZ [OAUTH2.0])
1919

20+
Route::get('/version', function () {
21+
$versionFile = base_path('version.json');
22+
23+
// Check if file exists
24+
if (!file_exists($versionFile)) {
25+
return response()->json(['error' => 'Version information not found'], 404);
26+
}
27+
28+
// Read file contents
29+
$contents = file_get_contents($versionFile);
30+
31+
// Decode JSON
32+
$versionData = json_decode($contents, true);
33+
34+
// Check if JSON is valid or empty
35+
if ($versionData === null && json_last_error() !== JSON_ERROR_NONE) {
36+
return response()->json(['error' => 'Version information malformed'], 412);
37+
}
38+
39+
if (empty($versionData)) {
40+
return response()->json(['error' => 'Version information malformed'], 412);
41+
}
42+
43+
return response()->json($versionData, 200);
44+
});
2045

2146
Route::group(['prefix' => 'sponsored-projects'], function(){
2247
Route::get('', 'OAuth2SponsoredProjectApiController@getAll');

version.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"service": "summit-api",
3+
"git_sha": "dev",
4+
"git_tag": "dev"
5+
}

0 commit comments

Comments
 (0)