aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/host-meta.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/server/middleware/host-meta.js')
-rw-r--r--vnext/server/middleware/host-meta.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/vnext/server/middleware/host-meta.js b/vnext/server/middleware/host-meta.js
new file mode 100644
index 00000000..0bca925a
--- /dev/null
+++ b/vnext/server/middleware/host-meta.js
@@ -0,0 +1,42 @@
+import config from 'config'
+
+const baseURL = config.get('service.baseURL')
+
+/**
+ * host-meta endpoint
+ * @type {import('express').RequestParamHandler}
+ */
+export const xmlMeta = async (_req, res) => {
+ return res.set('Content-Type', 'text/xml')
+ .send(`<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="${baseURL}/.well-known/webfinger?resource={uri}"/></XRD>`)
+}
+
+/**
+ * host-meta.json endpoint
+ * @type {import('express').RequestParamHandler}
+ */
+export const jsonMeta = async (_req, res) => {
+ return res.json({
+ 'links': [
+ {
+ 'rel': 'lrdd',
+ 'template': `${baseURL}/.well-known/webfinger?resource={uri}`
+ }
+ ]
+ })
+}
+
+/**
+ * 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`
+ }
+ ]
+ })
+}