import path from "path";
export default async ({ res }: { res: Response }) => {
- res.setHeader("Content-Type", "application/javascript");
-
- res.sendFile(
- path.resolve(
- `./dist/service-worker${
- process.env.NODE_ENV === "development" ? "-development" : ""
- }.js`
- )
- );
+ res
+ .setHeader("Content-Type", "application/javascript")
+ .sendFile(
+ path.resolve(
+ `./dist/service-worker${
+ process.env.NODE_ENV === "development" ? "-development" : ""
+ }.js`
+ )
+ );
};
import { buildThemeList } from "../utils/build-themes-list";
export default async ({ res }: { res: Response }) => {
- res.type("json");
- res.send(JSON.stringify(await buildThemeList()));
+ res.type("json").send(JSON.stringify(await buildThemeList()));
};
"Content-Security-Policy",
`default-src 'self'; manifest-src *; connect-src *; img-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; form-action 'self'; base-uri 'self'; frame-src *; media-src *`
);
+
next();
}
const extraThemesFolder =
process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
+const themes = ["darkly", "darkly-red", "litely", "litely-red"];
+
export async function buildThemeList(): Promise<string[]> {
- const themes = ["darkly", "darkly-red", "litely", "litely-red"];
if (existsSync(extraThemesFolder)) {
const dirThemes = await readdir(extraThemesFolder);
const cssThemes = dirThemes
isoData: IsoDataOptionalSite
) {
const site = isoData.site_res;
+
const appleTouchIcon = site?.site_view.site.icon
? `data:image/png;base64,${sharp(
await fetchIconPng(site.site_view.site.icon)
const adminMatrixIds = site?.admins
.map(({ person: { matrix_user_id } }) => matrix_user_id)
.filter(id => id) as string[] | undefined;
+
if (adminMatrixIds && adminMatrixIds.length > 0) {
errorPageData.adminMatrixIds = adminMatrixIds;
}
[key: string]: string;
} {
const out: { [key: string]: string } = {};
+
if (headers.host) {
out.host = headers.host;
}
+
const realIp = headers["x-real-ip"];
+
if (realIp) {
out["x-real-ip"] = realIp as string;
}
+
const forwardedFor = headers["x-forwarded-for"];
+
if (forwardedFor) {
out["x-forwarded-for"] = forwardedFor as string;
}