mirror of
https://github.com/antos-rde/antos-backend.git
synced 2024-12-25 20:58:22 +01:00
feat: add versions info to API
All checks were successful
gitea-sync/antos-backend/pipeline/head This commit looks good
All checks were successful
gitea-sync/antos-backend/pipeline/head This commit looks good
This commit is contained in:
parent
37f68f0e04
commit
ac36ba6ff0
3
Makefile
3
Makefile
@ -1,10 +1,11 @@
|
||||
DESTDIR?=/opt/www/htdocs/os
|
||||
|
||||
BUILDID:=$(shell git rev-parse --short HEAD)
|
||||
all:
|
||||
- mkdir -p $(DESTDIR)
|
||||
cp router.lua mimes.json $(DESTDIR)
|
||||
cp -rf controllers $(DESTDIR)
|
||||
cp -rf libs $(DESTDIR)
|
||||
sed -i '1s/^/API_REF="$(BUILDID)"\n/' $(DESTDIR)/router.lua
|
||||
clean:
|
||||
rm -rf $(DESTDIR)/router.lua $(DESTDIR)/mimes.json \
|
||||
$(DESTDIR)/controllers $(DESTDIR)/libs
|
@ -20,7 +20,7 @@ function IndexController:doc(...)
|
||||
author = "Xuan Sang LE",
|
||||
email = "xsang.le@gmail.com",
|
||||
api_name = "AntOS API",
|
||||
version = "2.0.0-a",
|
||||
version = API_VERSION,
|
||||
documents = {
|
||||
vfs = HTTP_ROOT.."/VFS",
|
||||
user = HTTP_ROOT.."/user",
|
||||
|
@ -17,7 +17,8 @@ function SystemController:index(...)
|
||||
["/packages"] = "Handle all operation relate to package: list, install, cache, uninstall",
|
||||
["/settings"] = "Save user setting",
|
||||
["/application"] = "Call a specific server side application api",
|
||||
["/apigateway"] = "Gateway for executing custom server side code"
|
||||
["/apigateway"] = "Gateway for executing custom server side code",
|
||||
["/version"] = "All component versions"
|
||||
}
|
||||
}
|
||||
result(api)
|
||||
@ -248,3 +249,18 @@ function SystemController:apigateway(...)
|
||||
cout('{"error":"User unauthorized. Please login"}')
|
||||
end
|
||||
end
|
||||
|
||||
function SystemController:version(...)
|
||||
auth_or_die("User unauthorized. Please login")
|
||||
local versions = {}
|
||||
local version_file = string.format('%s/libs/versions.json', WWW_ROOT)
|
||||
if ulib.exists(version_file) then
|
||||
versions = JSON.decodeFile(version_file)
|
||||
end
|
||||
versions["REST"] = { version = API_VERSION, ref = "unknown" }
|
||||
if API_REF then
|
||||
versions["REST"]["ref"] = API_REF
|
||||
end
|
||||
result(versions)
|
||||
return false
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
-- API version
|
||||
API_VERSION = "2.1.0"
|
||||
-- the rewrite rule for the framework
|
||||
-- should be something like this
|
||||
-- ^\/apps\/+(.*)$ = /apps/router.lua?r=<1>&<query>
|
||||
|
Loading…
Reference in New Issue
Block a user