From b568756b83a932ca9bdb20aa8e28c50f96fdaabb Mon Sep 17 00:00:00 2001
From: Alec Armbruster <alectrocute@gmail.com>
Date: Fri, 16 Jun 2023 10:42:35 -0400
Subject: [PATCH] formatting

---
 src/server/handlers/service-worker-handler.ts | 18 +++++++++---------
 src/server/handlers/themes-list-handler.ts    |  3 +--
 src/server/middleware/set-default-csp.ts      |  1 +
 src/server/utils/build-themes-list.ts         |  3 ++-
 src/server/utils/create-ssr-html.tsx          |  1 +
 src/server/utils/get-error-page-data.ts       |  1 +
 src/server/utils/set-forwarded-headers.ts     |  5 +++++
 7 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/server/handlers/service-worker-handler.ts b/src/server/handlers/service-worker-handler.ts
index 886aa09..15c6b3f 100644
--- a/src/server/handlers/service-worker-handler.ts
+++ b/src/server/handlers/service-worker-handler.ts
@@ -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`
+      )
+    );
 };
diff --git a/src/server/handlers/themes-list-handler.ts b/src/server/handlers/themes-list-handler.ts
index 1a54f92..f36497e 100644
--- a/src/server/handlers/themes-list-handler.ts
+++ b/src/server/handlers/themes-list-handler.ts
@@ -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()));
 };
diff --git a/src/server/middleware/set-default-csp.ts b/src/server/middleware/set-default-csp.ts
index 5b6f72a..a3ee526 100644
--- a/src/server/middleware/set-default-csp.ts
+++ b/src/server/middleware/set-default-csp.ts
@@ -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();
 }
diff --git a/src/server/utils/build-themes-list.ts b/src/server/utils/build-themes-list.ts
index c6aa770..73dc53b 100644
--- a/src/server/utils/build-themes-list.ts
+++ b/src/server/utils/build-themes-list.ts
@@ -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
diff --git a/src/server/utils/create-ssr-html.tsx b/src/server/utils/create-ssr-html.tsx
index d23c6da..5cc38d7 100644
--- a/src/server/utils/create-ssr-html.tsx
+++ b/src/server/utils/create-ssr-html.tsx
@@ -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)
diff --git a/src/server/utils/get-error-page-data.ts b/src/server/utils/get-error-page-data.ts
index af5c811..3c82372 100644
--- a/src/server/utils/get-error-page-data.ts
+++ b/src/server/utils/get-error-page-data.ts
@@ -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;
   }
diff --git a/src/server/utils/set-forwarded-headers.ts b/src/server/utils/set-forwarded-headers.ts
index d825c60..386bd7d 100644
--- a/src/server/utils/set-forwarded-headers.ts
+++ b/src/server/utils/set-forwarded-headers.ts
@@ -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;
   }
-- 
2.44.1