refactor: add sping/ping into openapi

change getObject to getSortedSetRange so db is always checked. getObject calls are cached
This commit is contained in:
Barış Soner Uşaklı
2025-04-24 09:50:52 -04:00
parent 7eb2f12751
commit 8ffbc35923
4 changed files with 31 additions and 1 deletions

View File

@@ -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:

View File

@@ -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"

View File

@@ -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"

View File

@@ -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);