feat(api): Add TOS and Privacy Policy support

This commit is contained in:
Jesse Wierzbinski 2024-06-11 09:55:40 -10:00
parent e9e33432c2
commit ffcf01e3cd
No known key found for this signature in database
12 changed files with 180 additions and 33 deletions

31
utils/markdown.ts Normal file
View file

@ -0,0 +1,31 @@
import { markdownParse } from "~/database/entities/Status";
import { LogLevel } from "~/packages/log-manager";
import { dualLogger } from "./loggers";
export const renderMarkdownInPath = async (
path: string,
defaultText?: string,
) => {
let content = await markdownParse(defaultText ?? "");
let lastModified = new Date(1970, 0, 0);
const extended_description_file = Bun.file(path || "");
if (path && (await extended_description_file.exists())) {
content =
(await markdownParse(
(await extended_description_file.text().catch(async (e) => {
await dualLogger.logError(LogLevel.ERROR, "Routes", e);
return "";
})) ||
defaultText ||
"",
)) || "";
lastModified = new Date(extended_description_file.lastModified);
}
return {
content: content,
lastModified,
};
};