aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/host-meta.js
blob: eec7d3e360ec1d310f5bc38205f709b741595e33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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}`
            }
        ]
    })
}