]> Untitled Git - lemmy-ui.git/commitdiff
formatting
authorAlec Armbruster <alectrocute@gmail.com>
Fri, 16 Jun 2023 14:42:35 +0000 (10:42 -0400)
committerAlec Armbruster <alectrocute@gmail.com>
Fri, 16 Jun 2023 14:42:35 +0000 (10:42 -0400)
src/server/handlers/service-worker-handler.ts
src/server/handlers/themes-list-handler.ts
src/server/middleware/set-default-csp.ts
src/server/utils/build-themes-list.ts
src/server/utils/create-ssr-html.tsx
src/server/utils/get-error-page-data.ts
src/server/utils/set-forwarded-headers.ts

index 886aa0931fd0303aa281fcd2fa49f6eb3be0be75..15c6b3fb649e1295d7da7e1e4f8bb84a938b9a76 100644 (file)
@@ -2,13 +2,13 @@ import type { Response } from "express";
 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`
+      )
+    );
 };
index 1a54f924e66cd62cb580e0864710713de005d270..f36497e4610efad202544148cc38af9fe3b43c0c 100644 (file)
@@ -2,6 +2,5 @@ import type { Response } from "express";
 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()));
 };
index 5b6f72a398b657c527cb7074b4dabffc49cb2a21..a3ee52613930d991d6622ad85514096d4ec285d0 100644 (file)
@@ -5,5 +5,6 @@ export default function ({ res, next }: { res: Response; next: NextFunction }) {
     "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();
 }
index c6aa7706fcd850aea96c24f1da69282d989db1b8..73dc53bcad4d3df324c7e436a8d520da7ef2c5cb 100644 (file)
@@ -4,8 +4,9 @@ import { readdir } from "fs/promises";
 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
index d23c6dabad62d5c4bcd0a1e9a1878e1ef28e18a0..5cc38d7dc3df4314d8491f5072ed07a09b168886 100644 (file)
@@ -14,6 +14,7 @@ export async function createSsrHtml(
   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)
index af5c8118e9dec8965e675d3920fa9874390ba498..3c82372f18592ed2576f6eca0ddc028ab6e0a9c1 100644 (file)
@@ -11,6 +11,7 @@ export function getErrorPageData(error: Error, site?: GetSiteResponse) {
   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;
   }
index d825c60be2eec481633eeabd082052b0bf21d006..386bd7dbbbfdf266779db9ef113bd315149a6c5e 100644 (file)
@@ -4,14 +4,19 @@ export function setForwardedHeaders(headers: IncomingHttpHeaders): {
   [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;
   }