From d2e3ee78415198b3d73b7907a8a2fdb4d2ce9194 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 22 Oct 2024 09:01:06 +0300 Subject: vnext: `/.well-known/nodeinfo` endpoint --- vnext/server/app.js | 6 +++++- vnext/server/middleware/host-meta.js | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/vnext/server/app.js b/vnext/server/app.js index f8beb933..223868f1 100644 --- a/vnext/server/app.js +++ b/vnext/server/app.js @@ -13,7 +13,7 @@ import { instance } from './middleware/mastodon' import path from 'path' import { webhook, webhookPath } from './durov' import { webfinger } from './middleware/webfinger' -import { jsonMeta, xmlMeta } from './middleware/host-meta' +import { jsonMeta, nodeinfo, xmlMeta } from './middleware/host-meta' // initialize the application and create the routes export const app = express() @@ -35,6 +35,10 @@ router.get('/.well-known/host-meta.json', jsonMeta) router.get('/.well-known/webfinger', webfinger) +// Nodeinfo + +router.get('/.well-known/nodeinfo', nodeinfo) + // Mastodon API router.get('/api/v2/instance', instance) diff --git a/vnext/server/middleware/host-meta.js b/vnext/server/middleware/host-meta.js index eec7d3e3..fe6ca631 100644 --- a/vnext/server/middleware/host-meta.js +++ b/vnext/server/middleware/host-meta.js @@ -15,7 +15,7 @@ export const xmlMeta = async (_req, res) => { } /** - * host-meta endpoint + * host-meta.json endpoint * @type {import('express').RequestParamHandler} */ export const jsonMeta = async (_req, res) => { @@ -28,3 +28,18 @@ export const jsonMeta = async (_req, res) => { ] }) } + +/** + * nodeinfo endpoint + * @type {import('express').RequestParamHandler} + */ +export const nodeinfo = async (_req, res) => { + return res.json({ + 'links': [ + { + 'rel': 'https://nodeinfo.diaspora.software/ns/schema/2.0', + 'href': `${baseURL}/.well-known/nodeinfo/2.0` + } + ] + }) +} -- cgit v1.2.3