server/server/api/well-known/host-meta/index.ts
2024-08-19 20:06:38 +02:00

27 lines
766 B
TypeScript

import { apiRoute, applyConfig } from "@/api";
import { xmlResponse } from "@/response";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({
allowedMethods: ["GET"],
auth: {
required: false,
},
ratelimits: {
duration: 60,
max: 60,
},
route: "/.well-known/host-meta",
});
export default apiRoute((app) =>
app.on(meta.allowedMethods, meta.route, () => {
return xmlResponse(
`<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="${new URL(
"/.well-known/webfinger",
config.http.base_url,
).toString()}?resource={uri}"/></XRD>`,
);
}),
);