aboutsummaryrefslogtreecommitdiff
path: root/vnext/server
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/server')
-rw-r--r--vnext/server/app.js6
-rw-r--r--vnext/server/middleware/host-meta.js30
2 files changed, 36 insertions, 0 deletions
diff --git a/vnext/server/app.js b/vnext/server/app.js
index b2ba4cf6..f8beb933 100644
--- a/vnext/server/app.js
+++ b/vnext/server/app.js
@@ -13,6 +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'
// initialize the application and create the routes
export const app = express()
@@ -25,6 +26,11 @@ router.get('/api/v2/oembed', oembed)
router.get('/api/v2/urlexpand', urlExpand)
router.get('/api/apps/android/releases', releases)
+// Web Host Metadata
+
+router.get('/.well-known/host-meta', xmlMeta)
+router.get('/.well-known/host-meta.json', jsonMeta)
+
// WebFinger
router.get('/.well-known/webfinger', webfinger)
diff --git a/vnext/server/middleware/host-meta.js b/vnext/server/middleware/host-meta.js
new file mode 100644
index 00000000..eec7d3e3
--- /dev/null
+++ b/vnext/server/middleware/host-meta.js
@@ -0,0 +1,30 @@
+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 endpoint
+ * @type {import('express').RequestParamHandler}
+ */
+export const jsonMeta = async (_req, res) => {
+ return res.json({
+ 'links': [
+ {
+ 'rel': 'lrdd',
+ 'template': `${baseURL}/.well-known/webfinger?resource={uri}`
+ }
+ ]
+ })
+}