From e52d965d02621981a1fe1250e06437aef46a8198 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sat, 27 Jan 2024 22:12:43 +0100 Subject: [PATCH] fix: move version endpoint --- src/api/v3/index.js | 14 -------------- src/routes/main.js | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api/v3/index.js b/src/api/v3/index.js index 5d30412..80a0d28 100644 --- a/src/api/v3/index.js +++ b/src/api/v3/index.js @@ -30,23 +30,9 @@ more information on this, and how to apply and follow the GNU AGPL, see { - // TODO Support responding with JSON object when requested - - let versionDetails = app.get('git_branch') - ? `+${app.get('git_branch')}` - : '' - versionDetails += (app.get('git_branch') && app.get('git_hash')) - ? `.${app.get('git_hash').substring(0, 10)}` - : '' - - return res.status(200).contentType('text/plain').send(`${app.get('keyoxide_name')}/${app.get('keyoxide_version')}${versionDetails}`) -}) - if ((process.env.ENABLE_MAIN_MODULE ?? 'true') === 'true') { router.use('/profile', keyoxideProfileApiRouter) } diff --git a/src/routes/main.js b/src/routes/main.js index 9c1f3df..65ff1de 100644 --- a/src/routes/main.js +++ b/src/routes/main.js @@ -31,6 +31,7 @@ import express from 'express' import markdownImport from 'markdown-it' import { readFileSync } from 'fs' import { getMetaFromReq } from '../server/utils.js' +import app from '../index.js' const router = express.Router() const md = markdownImport({ typographer: true }) @@ -79,6 +80,19 @@ router.get('/.well-known/webfinger', (req, res) => { res.json(body) }) +router.get('/.well-known/keyoxide/version', async (req, res) => { + // TODO Support responding with JSON object when requested + + let versionDetails = app.get('git_branch') + ? `+${app.get('git_branch')}` + : '' + versionDetails += (app.get('git_branch') && app.get('git_hash')) + ? `.${app.get('git_hash').substring(0, 10)}` + : '' + + return res.status(200).contentType('text/plain').send(`${app.get('keyoxide_name')}/${app.get('keyoxide_version')}${versionDetails}`) +}) + router.get('/users/keyoxide', (req, res) => { if (!(process.env.DOMAIN && process.env.ACTIVITYPUB_PUBLIC_KEY)) { res.status(404).send('
Cannot GET /keyoxide
')