diff options
author | Vitaly Takmazov | 2024-10-22 08:50:02 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-10-22 08:50:02 +0300 |
commit | 7e6601867f08b31cc3ee4373ec748ac1aba2f6cf (patch) | |
tree | 8a182ec29e560a5dcdf2afe0c223a9112773f66e /vnext/server/middleware | |
parent | 1386cbcb9e84c37cc5d6164028499e60219c439c (diff) |
vnext: RFC 6415: Web Host Metadata
Diffstat (limited to 'vnext/server/middleware')
-rw-r--r-- | vnext/server/middleware/host-meta.js | 30 |
1 files changed, 30 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..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}` + } + ] + }) +} |