summaryrefslogtreecommitdiff
path: root/server.mjs
diff options
context:
space:
mode:
authorLi Zhineng <[email protected]>2025-07-02 20:45:20 +0800
committerGitHub <[email protected]>2025-07-02 20:45:20 +0800
commitfd5876743c2070a5259c36110e7e02f80ed80458 (patch)
treea91673aba254eab609f086d203fd1fe5c90c36bb /server.mjs
parent6c131da8eb6e20c6fceed35f548c8c0921239e6b (diff)
parent40085a4679d88d2c0a141b95ee6818ac7420dae3 (diff)
downloadserver-fd5876743c2070a5259c36110e7e02f80ed80458.tar.gz
server-fd5876743c2070a5259c36110e7e02f80ed80458.zip
Merge pull request #2 from openairmx/genid
Update the payload data structure for the device registration endpoint
Diffstat (limited to 'server.mjs')
-rw-r--r--server.mjs20
1 files changed, 17 insertions, 3 deletions
diff --git a/server.mjs b/server.mjs
index ff9d7ba..2475442 100644
--- a/server.mjs
+++ b/server.mjs
@@ -30,10 +30,24 @@ const getTimeControlller = (req, res) => {
const eagleController = (req, res) => {
const [, query] = req.url.split('?')
const params = new URLSearchParams(query)
- const mac = params.get('mac')
- const key = params.get('key')
- if (mac === null || key === null) {
+ switch (params.get('path')) {
+ case 'eagle/GET/genId':
+ eagleGenIdController(req, res)
+ break
+ default:
+ notFoundController(req, res)
+ break
+ }
+}
+
+const eagleGenIdController = (req, res) => {
+ const [, query] = req.url.split('?')
+ const params = new URLSearchParams(query)
+ const { mac, key } = JSON.parse(params.get('params') || '{}')
+
+ if (mac === undefined || mac === null
+ || key === undefined || key === null) {
res.writeHead(400, { 'Content-Type': 'application/json' })
res.end('{}\n')
return