From 09781ff7ca439b0d24b4757d09e8325b48a9341c Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Mon, 02 Jun 2025 09:35:50 +0000
Subject: [PATCH] adding new Routes for obj_id and ref_id

---
 app.js |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/app.js b/app.js
index cd1c41a..402324d 100644
--- a/app.js
+++ b/app.js
@@ -1,7 +1,9 @@
 const fastify = require('fastify')({
    logger: true
 })
+const _ = require("lodash")
 const db = require("./lib/db")
+
 const settings = require("./settings")
 
 /////////////////////////////////////////////////////////////////////////
@@ -48,6 +50,26 @@
          return res.code(404).send({status: "error", msg: "not found"})
       }
    })
+   .get("/ref_id/:ref_id", async function (req, res) {
+      const {ref_id} = req.params
+      const data = await db.getObjIdFromRefId(ref_id)
+      if (data) {
+         return res.send(data)
+      }
+      else {
+         return res.code(404).send({status: "error", msg: "not found"})
+      }
+   })
+   .get("/obj_id/:obj_id", async function (req, res) {
+      const {obj_id} = req.params
+      let data = await db.getRefIdFromObjId(obj_id)
+      if (data) {
+         return res.send(data)
+      }
+      else {
+         return res.code(404).send({status: "error", msg: "not found"})
+      }
+   })
 
 
 /////////////////////////////////////////////////////////////////////////
@@ -62,6 +84,6 @@
 
 /////////////////////////////////////////////////////////////////////////
 
-async function promiseDelay(ms) {
-    return new Promise(resolve => setTimeout(resolve, ms))
+async function promiseDelay (ms) {
+   return new Promise(resolve => setTimeout(resolve, ms))
 }

--
Gitblit v1.8.0