From acc54a55bc2b43dc47acaf1241fe50865fb940f4 Mon Sep 17 00:00:00 2001 From: sam Date: Fri, 6 Sep 2024 15:01:44 +0200 Subject: [PATCH] format(frontend): change line width to 100 --- .../Middleware/AuthorizationMiddleware.cs | 3 +- Foxnouns.Frontend/.prettierrc | 3 +- Foxnouns.Frontend/app/app.scss | 2 +- Foxnouns.Frontend/app/components/nav/Logo.tsx | 5 +- .../app/components/nav/Navbar.tsx | 59 +++++++++---------- Foxnouns.Frontend/app/entry.server.tsx | 26 ++------ Foxnouns.Frontend/app/lib/request.server.ts | 14 +---- Foxnouns.Frontend/app/root.tsx | 6 +- Foxnouns.Frontend/server.js | 9 +-- 9 files changed, 43 insertions(+), 84 deletions(-) diff --git a/Foxnouns.Backend/Middleware/AuthorizationMiddleware.cs b/Foxnouns.Backend/Middleware/AuthorizationMiddleware.cs index 6d4bc49..1cab41c 100644 --- a/Foxnouns.Backend/Middleware/AuthorizationMiddleware.cs +++ b/Foxnouns.Backend/Middleware/AuthorizationMiddleware.cs @@ -18,7 +18,8 @@ public class AuthorizationMiddleware : IMiddleware var token = ctx.GetToken(); if (token == null) - throw new ApiError.Unauthorized("This endpoint requires an authenticated user.", ErrorCode.AuthenticationRequired); + throw new ApiError.Unauthorized("This endpoint requires an authenticated user.", + ErrorCode.AuthenticationRequired); if (attribute.Scopes.Length > 0 && attribute.Scopes.Except(token.Scopes.ExpandScopes()).Any()) throw new ApiError.Forbidden("This endpoint requires ungranted scopes.", attribute.Scopes.Except(token.Scopes.ExpandScopes()), ErrorCode.MissingScopes); diff --git a/Foxnouns.Frontend/.prettierrc b/Foxnouns.Frontend/.prettierrc index c959087..cb96cd0 100644 --- a/Foxnouns.Frontend/.prettierrc +++ b/Foxnouns.Frontend/.prettierrc @@ -1,3 +1,4 @@ { - "useTabs": true + "useTabs": true, + "printWidth": 100 } diff --git a/Foxnouns.Frontend/app/app.scss b/Foxnouns.Frontend/app/app.scss index 19155ce..c7b7086 100644 --- a/Foxnouns.Frontend/app/app.scss +++ b/Foxnouns.Frontend/app/app.scss @@ -18,4 +18,4 @@ $font-family-sans-serif: @import "@fontsource/firago/400.css"; @import "@fontsource/firago/400-italic.css"; -@import "@fontsource/firago/700.css"; \ No newline at end of file +@import "@fontsource/firago/700.css"; diff --git a/Foxnouns.Frontend/app/components/nav/Logo.tsx b/Foxnouns.Frontend/app/components/nav/Logo.tsx index 216eb54..f1c8e40 100644 --- a/Foxnouns.Frontend/app/components/nav/Logo.tsx +++ b/Foxnouns.Frontend/app/components/nav/Logo.tsx @@ -13,10 +13,7 @@ export default function Logo() { - + + - + - - - Theme - - } - align="end" - > - - Automatic - - - Dark mode - - - Light mode - - - ); } diff --git a/Foxnouns.Frontend/app/entry.server.tsx b/Foxnouns.Frontend/app/entry.server.tsx index 5e213e2..7b1af99 100644 --- a/Foxnouns.Frontend/app/entry.server.tsx +++ b/Foxnouns.Frontend/app/entry.server.tsx @@ -25,18 +25,8 @@ export default function handleRequest( loadContext: AppLoadContext, ) { return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext, - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext, - ); + ? handleBotRequest(request, responseStatusCode, responseHeaders, remixContext) + : handleBrowserRequest(request, responseStatusCode, responseHeaders, remixContext); } function handleBotRequest( @@ -48,11 +38,7 @@ function handleBotRequest( return new Promise((resolve, reject) => { let shellRendered = false; const { pipe, abort } = renderToPipeableStream( - , + , { onAllReady() { shellRendered = true; @@ -98,11 +84,7 @@ function handleBrowserRequest( return new Promise((resolve, reject) => { let shellRendered = false; const { pipe, abort } = renderToPipeableStream( - , + , { onShellReady() { shellRendered = true; diff --git a/Foxnouns.Frontend/app/lib/request.server.ts b/Foxnouns.Frontend/app/lib/request.server.ts index 144edbe..d7add9b 100644 --- a/Foxnouns.Frontend/app/lib/request.server.ts +++ b/Foxnouns.Frontend/app/lib/request.server.ts @@ -35,15 +35,11 @@ export default async function serverRequest( } as ApiError; } - if (resp.status < 200 || resp.status >= 400) - throw (await resp.json()) as ApiError; + if (resp.status < 200 || resp.status >= 400) throw (await resp.json()) as ApiError; return (await resp.json()) as T; } -export function getCookie( - req: Request, - cookieName: string, -): string | undefined { +export function getCookie(req: Request, cookieName: string): string | undefined { const header = req.headers.get("Cookie"); if (!header) return undefined; @@ -53,11 +49,7 @@ export function getCookie( const YEAR = 365 * 86400; -export const writeCookie = ( - cookieName: string, - value: string, - maxAge: number | undefined = YEAR, -) => +export const writeCookie = (cookieName: string, value: string, maxAge: number | undefined = YEAR) => serializeCookie(cookieName, value, { maxAge, path: "/", diff --git a/Foxnouns.Frontend/app/root.tsx b/Foxnouns.Frontend/app/root.tsx index d1c62f3..de5e053 100644 --- a/Foxnouns.Frontend/app/root.tsx +++ b/Foxnouns.Frontend/app/root.tsx @@ -32,11 +32,7 @@ export const loader: LoaderFunction = async ({ request }) => { const user = await serverRequest("GET", "/users/@me", { token }); meUser = user; - settings = await serverRequest( - "GET", - "/users/@me/settings", - { token }, - ); + settings = await serverRequest("GET", "/users/@me/settings", { token }); } catch (e) { // If we get an unauthorized error, clear the token, as it's not valid anymore. if ((e as ApiError).code === ErrorCode.AuthenticationRequired) { diff --git a/Foxnouns.Frontend/server.js b/Foxnouns.Frontend/server.js index ed053cf..e9e6c4b 100644 --- a/Foxnouns.Frontend/server.js +++ b/Foxnouns.Frontend/server.js @@ -31,10 +31,7 @@ if (viteDevServer) { app.use(viteDevServer.middlewares); } else { // Vite fingerprints its assets so we can cache forever. - app.use( - "/assets", - express.static("build/client/assets", { immutable: true, maxAge: "1y" }), - ); + app.use("/assets", express.static("build/client/assets", { immutable: true, maxAge: "1y" })); } // Everything else (like favicon.ico) is cached for an hour. You may want to be @@ -47,6 +44,4 @@ app.use(morgan("tiny")); app.all("*", remixHandler); const port = env.PORT || 3000; -app.listen(port, () => - console.log(`Express server listening at http://localhost:${port}`), -); +app.listen(port, () => console.log(`Express server listening at http://localhost:${port}`));