diff --git a/scripts/start.sh b/scripts/start.sh index 354f528..07a0df8 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -59,10 +59,12 @@ $LUA_COMMAND -e "require('socket')" 2>/dev/null || { exit 1 } -$LUA_COMMAND -e "require('cjson')" 2>/dev/null || { - echo -e "${RED}Error: lua-cjson not found${NC}" +# JSON library check (cjson preferred, dkjson fallback) +if ! ($LUA_COMMAND -e "require('cjson')" 2>/dev/null || $LUA_COMMAND -e "require('dkjson')" 2>/dev/null); then + echo -e "${RED}Error: No JSON library found${NC}" + echo "Install lua-cjson or lua-dkjson" exit 1 -} +fi cd "$PROJECT_DIR" diff --git a/src/main.lua b/src/main.lua index 8ee7281..5773714 100644 --- a/src/main.lua +++ b/src/main.lua @@ -3,7 +3,10 @@ -- Dragons@Work Digital Sovereignty Project local socket = require("socket") -local cjson = require("cjson") +local found_cjson, cjson = pcall(require, 'cjson') +if not found_cjson then + cjson = require('dkjson') +end -- Load modules local Auth = require("src.auth") diff --git a/src/routes/mail.lua b/src/routes/mail.lua index d7cd93f..8e59b03 100644 --- a/src/routes/mail.lua +++ b/src/routes/mail.lua @@ -3,7 +3,10 @@ -- API-Key determines mail configuration and recipient -- Dragons@Work Digital Sovereignty Project -local cjson = require("cjson") +local found_cjson, cjson = pcall(require, 'cjson') +if not found_cjson then + cjson = require('dkjson') +end local MailRoute = {}