mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: add sping/ping into openapi
change getObject to getSortedSetRange so db is always checked. getObject calls are cached
This commit is contained in:
@@ -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:
|
||||
|
||||
13
public/openapi/read/ping.yaml
Normal file
13
public/openapi/read/ping.yaml
Normal 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"
|
||||
13
public/openapi/read/sping.yaml
Normal file
13
public/openapi/read/sping.yaml
Normal 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"
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user