From b0d3d1edde17ad77db4bcd59b99c159599bdb289 Mon Sep 17 00:00:00 2001 From: jmt-gh Date: Thu, 9 Jun 2022 09:02:43 -0700 Subject: [PATCH] Add an API endpoint for GETing server version This commit adds an API endpoint to get the server version. This will be used to add the ability for the mobile app to show which server version the server you are currently connected to is running. --- server/controllers/MiscController.js | 9 +++++++++ server/routers/ApiRouter.js | 1 + 2 files changed, 10 insertions(+) diff --git a/server/controllers/MiscController.js b/server/controllers/MiscController.js index d16c9c8f7..19f280e27 100644 --- a/server/controllers/MiscController.js +++ b/server/controllers/MiscController.js @@ -159,6 +159,15 @@ class MiscController { res.json(downloads) } + // GET: api/version + async getServerVersion(req, res) { + var version = { + serverVersion: this.db.serverSettings.version + } + + return res.json(version) + } + // PATCH: api/settings (admin) async updateServerSettings(req, res) { if (!req.user.isAdminOrUp) { diff --git a/server/routers/ApiRouter.js b/server/routers/ApiRouter.js index e9b88c8c7..5e106828c 100644 --- a/server/routers/ApiRouter.js +++ b/server/routers/ApiRouter.js @@ -202,6 +202,7 @@ class ApiRouter { this.router.delete('/download/:id', MiscController.removeDownload.bind(this)) this.router.get('/downloads', MiscController.getDownloads.bind(this)) this.router.patch('/settings', MiscController.updateServerSettings.bind(this)) // Root only + this.router.get('/version', MiscController.getServerVersion.bind(this)) this.router.post('/purgecache', MiscController.purgeCache.bind(this)) // Root only this.router.post('/authorize', MiscController.authorize.bind(this)) this.router.get('/search/covers', MiscController.findCovers.bind(this))