From d90c8ded64885a012af061c2ab3fe3445c12fb23 Mon Sep 17 00:00:00 2001 From: Andrew Pietila Date: Wed, 12 Apr 2023 00:06:39 -0500 Subject: [PATCH] Add basic nodeinfo. --- routes/.well-known/nodeinfo.js | 20 ++++++++++++++++++++ routes/nodeinfo/2.0.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 routes/.well-known/nodeinfo.js create mode 100644 routes/nodeinfo/2.0.js diff --git a/routes/.well-known/nodeinfo.js b/routes/.well-known/nodeinfo.js new file mode 100644 index 0000000..2e90670 --- /dev/null +++ b/routes/.well-known/nodeinfo.js @@ -0,0 +1,20 @@ +'use strict'; + +const express = require('express'); + +module.exports = { + /** + * @param {express.IRoute} routeObj + */ + route: (routeObj) => { + routeObj.get(async (req, res, _next) => { + res.json({ + "links": [{ + "rel": "http://nodeinfo.diaspora.software/ns/schema/2.0", + "href": `https://${req.headers.host}/nodeinfo/2.0` + }] + }); + res.end(); + }); + } +}; diff --git a/routes/nodeinfo/2.0.js b/routes/nodeinfo/2.0.js new file mode 100644 index 0000000..9f84284 --- /dev/null +++ b/routes/nodeinfo/2.0.js @@ -0,0 +1,34 @@ +'use strict'; + +const express = require('express'); + +module.exports = { + /** + * @param {express.IRoute} routeObj + */ + route: (routeObj) => { + routeObj.get(async (req, res, _next) => { + res.header("content-type", "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.0#\""); + res.json({ + version: "2.0", + software: { + name: "haxsocial", + // TODO: Include a git depth and revision hash. + version: "0.0.0" + }, + protocols: [ + "activitypub" + ], + services: { + outbound: [], + inbound: [] + }, + usage: { + }, + openRegistrations: false, + metadata: {} + }); + res.end(); + }); + } +};