mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Add host-meta endpoint
This commit is contained in:
parent
a83648db48
commit
a499dfd231
18
server/api/.well-known/host-meta/index.ts
Normal file
18
server/api/.well-known/host-meta/index.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { MatchedRoute } from "bun";
|
||||
import { getHost } from "@config";
|
||||
import { xmlResponse } from "@response";
|
||||
|
||||
/**
|
||||
* Host meta endpoint
|
||||
*/
|
||||
export default async (
|
||||
req: Request,
|
||||
matchedRoute: MatchedRoute
|
||||
): Promise<Response> => {
|
||||
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="https://${getHost()}/.well-known/webfinger?resource={uri}"/>
|
||||
</XRD>
|
||||
`);
|
||||
};
|
||||
|
|
@ -10,6 +10,15 @@ export const jsonResponse = (data: object, status = 200) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const xmlResponse = (data: string, status = 200) => {
|
||||
return new Response(data, {
|
||||
headers: {
|
||||
"Content-Type": "application/xml",
|
||||
},
|
||||
status,
|
||||
});
|
||||
};
|
||||
|
||||
export const jsonLdResponse = (
|
||||
data: NodeObject | APActivity | APObject,
|
||||
status = 200
|
||||
|
|
|
|||
Loading…
Reference in a new issue