From 8ffbc35923cc8f9a785a8edb80d52991a885ec22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 24 Apr 2025 09:50:52 -0400 Subject: [PATCH] refactor: add sping/ping into openapi change getObject to getSortedSetRange so db is always checked. getObject calls are cached --- public/openapi/read.yaml | 4 ++++ public/openapi/read/ping.yaml | 13 +++++++++++++ public/openapi/read/sping.yaml | 13 +++++++++++++ src/controllers/ping.js | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 public/openapi/read/ping.yaml create mode 100644 public/openapi/read/sping.yaml diff --git a/public/openapi/read.yaml b/public/openapi/read.yaml index b43ad81909..3ec355bd95 100644 --- a/public/openapi/read.yaml +++ b/public/openapi/read.yaml @@ -66,6 +66,10 @@ tags: - name: other description: Other one-off routes that do not fit in a section of their own paths: + /sping: + $ref: 'read/sping.yaml' + /ping: + $ref: 'read/ping.yaml' /api/: $ref: 'read/index.yaml' /api/admin: diff --git a/public/openapi/read/ping.yaml b/public/openapi/read/ping.yaml new file mode 100644 index 0000000000..2000de8306 --- /dev/null +++ b/public/openapi/read/ping.yaml @@ -0,0 +1,13 @@ +get: + tags: + - ping + summary: Check if NodeBB is up + description: This route returns "200" and 200 status code if NodeBB is up and running. + responses: + "200": + description: "" + content: + text/plain: + schema: + type: string + example: "200" diff --git a/public/openapi/read/sping.yaml b/public/openapi/read/sping.yaml new file mode 100644 index 0000000000..9ef9642622 --- /dev/null +++ b/public/openapi/read/sping.yaml @@ -0,0 +1,13 @@ +get: + tags: + - ping + summary: Check if NodeBB is up + description: This route returns "healthy" and 200 status code if NodeBB is up and running. + responses: + "200": + description: "" + content: + text/plain: + schema: + type: string + example: "healthy" diff --git a/src/controllers/ping.js b/src/controllers/ping.js index dc4baed1f8..672c0e46e5 100644 --- a/src/controllers/ping.js +++ b/src/controllers/ping.js @@ -5,7 +5,7 @@ const db = require('../database'); module.exports.ping = async function (req, res, next) { try { - await db.getObject('config'); + await db.getSortedSetRange('plugins:active', 0, 0); res.status(200).send(req.path === `${nconf.get('relative_path')}/sping` ? 'healthy' : '200'); } catch (err) { next(err);