From a499dfd231a48a580b39af7994fff349c3b7c9a1 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 12 Sep 2023 19:33:08 -1000 Subject: [PATCH] Add host-meta endpoint --- server/api/.well-known/host-meta/index.ts | 18 ++++++++++++++++++ utils/response.ts | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100644 server/api/.well-known/host-meta/index.ts diff --git a/server/api/.well-known/host-meta/index.ts b/server/api/.well-known/host-meta/index.ts new file mode 100644 index 00000000..c6f9490e --- /dev/null +++ b/server/api/.well-known/host-meta/index.ts @@ -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 => { + return xmlResponse(` + + + + + `); +}; diff --git a/utils/response.ts b/utils/response.ts index 1ebd09e0..e881e93e 100644 --- a/utils/response.ts +++ b/utils/response.ts @@ -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