format(frontend): change line width to 100
This commit is contained in:
parent
fa71f3fb23
commit
acc54a55bc
9 changed files with 43 additions and 84 deletions
|
@ -18,7 +18,8 @@ public class AuthorizationMiddleware : IMiddleware
|
||||||
|
|
||||||
var token = ctx.GetToken();
|
var token = ctx.GetToken();
|
||||||
if (token == null)
|
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())
|
if (attribute.Scopes.Length > 0 && attribute.Scopes.Except(token.Scopes.ExpandScopes()).Any())
|
||||||
throw new ApiError.Forbidden("This endpoint requires ungranted scopes.",
|
throw new ApiError.Forbidden("This endpoint requires ungranted scopes.",
|
||||||
attribute.Scopes.Except(token.Scopes.ExpandScopes()), ErrorCode.MissingScopes);
|
attribute.Scopes.Except(token.Scopes.ExpandScopes()), ErrorCode.MissingScopes);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
"useTabs": true
|
"useTabs": true,
|
||||||
|
"printWidth": 100
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,7 @@ export default function Logo() {
|
||||||
</clipPath>
|
</clipPath>
|
||||||
</defs>
|
</defs>
|
||||||
<g transform="translate(-49.754 -142.39)">
|
<g transform="translate(-49.754 -142.39)">
|
||||||
<g
|
<g transform="matrix(.33073 0 0 -.33073 50.093 154.62)" clipPath="url(#clipPath16)">
|
||||||
transform="matrix(.33073 0 0 -.33073 50.093 154.62)"
|
|
||||||
clipPath="url(#clipPath16)"
|
|
||||||
>
|
|
||||||
<path
|
<path
|
||||||
d="m35.347 20.107-8.899 3.294-3.323 10.891c-0.128 0.42-0.516 0.708-0.956 0.708-0.439 0-0.828-0.288-0.956-0.708l-3.322-10.891-8.9-3.294c-0.393-0.146-0.653-0.52-0.653-0.938s0.26-0.793 0.653-0.937l8.896-3.293 3.323-11.223c0.126-0.425 0.516-0.716 0.959-0.716s0.833 0.291 0.959 0.716l3.324 11.223 8.896 3.293c0.392 0.144 0.652 0.519 0.652 0.937s-0.26 0.792-0.653 0.938"
|
d="m35.347 20.107-8.899 3.294-3.323 10.891c-0.128 0.42-0.516 0.708-0.956 0.708-0.439 0-0.828-0.288-0.956-0.708l-3.322-10.891-8.9-3.294c-0.393-0.146-0.653-0.52-0.653-0.938s0.26-0.793 0.653-0.937l8.896-3.293 3.323-11.223c0.126-0.425 0.516-0.716 0.959-0.716s0.833 0.291 0.959 0.716l3.324 11.223 8.896 3.293c0.392 0.144 0.652 0.519 0.652 0.937s-0.26 0.792-0.653 0.938"
|
||||||
fill="#aa8ed6"
|
fill="#aa8ed6"
|
||||||
|
|
|
@ -6,11 +6,7 @@ import Logo from "./Logo";
|
||||||
import Nav from "react-bootstrap/Nav";
|
import Nav from "react-bootstrap/Nav";
|
||||||
import Navbar from "react-bootstrap/Navbar";
|
import Navbar from "react-bootstrap/Navbar";
|
||||||
import NavDropdown from "react-bootstrap/NavDropdown";
|
import NavDropdown from "react-bootstrap/NavDropdown";
|
||||||
import {
|
import { BrightnessHigh, BrightnessHighFill, MoonFill } from "react-bootstrap-icons";
|
||||||
BrightnessHigh,
|
|
||||||
BrightnessHighFill,
|
|
||||||
MoonFill,
|
|
||||||
} from "react-bootstrap-icons";
|
|
||||||
|
|
||||||
export default function MainNavbar({
|
export default function MainNavbar({
|
||||||
user,
|
user,
|
||||||
|
@ -48,40 +44,39 @@ export default function MainNavbar({
|
||||||
? MoonFill
|
? MoonFill
|
||||||
: BrightnessHighFill;
|
: BrightnessHighFill;
|
||||||
|
|
||||||
|
const theme = settings.dark_mode ? "dark" : "light";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar expand="lg" className="mb-4 mx-2">
|
<Navbar expand="lg" className={`mb-4 mx-2 bg-${theme}`} color={theme} variant={theme}>
|
||||||
<Navbar.Brand to="/" as={Link}>
|
<Navbar.Brand to="/" as={Link}>
|
||||||
<Logo />
|
<Logo />
|
||||||
</Navbar.Brand>
|
</Navbar.Brand>
|
||||||
<Navbar.Toggle aria-controls="main-navbar" />
|
<Navbar.Toggle aria-controls="main-navbar" />
|
||||||
<Navbar.Collapse id="main-navbar">
|
<Navbar.Collapse id="main-navbar">
|
||||||
<Nav className="ms-auto">{userMenu}</Nav>
|
<Nav className="ms-auto">
|
||||||
|
{userMenu}
|
||||||
|
<fetcher.Form method="POST" action="/dark-mode">
|
||||||
|
<NavDropdown
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
<ThemeIcon /> Theme
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
align="end"
|
||||||
|
>
|
||||||
|
<NavDropdown.Item as="button" name="theme" value="auto" type="submit">
|
||||||
|
Automatic
|
||||||
|
</NavDropdown.Item>
|
||||||
|
<NavDropdown.Item as="button" name="theme" value="dark" type="submit">
|
||||||
|
Dark mode
|
||||||
|
</NavDropdown.Item>
|
||||||
|
<NavDropdown.Item as="button" name="theme" value="light" type="submit">
|
||||||
|
Light mode
|
||||||
|
</NavDropdown.Item>
|
||||||
|
</NavDropdown>
|
||||||
|
</fetcher.Form>
|
||||||
|
</Nav>
|
||||||
</Navbar.Collapse>
|
</Navbar.Collapse>
|
||||||
<fetcher.Form method="POST" action="/dark-mode">
|
|
||||||
<NavDropdown
|
|
||||||
title={
|
|
||||||
<>
|
|
||||||
<ThemeIcon /> Theme
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
align="end"
|
|
||||||
>
|
|
||||||
<NavDropdown.Item as="button" name="theme" value="auto" type="submit">
|
|
||||||
Automatic
|
|
||||||
</NavDropdown.Item>
|
|
||||||
<NavDropdown.Item as="button" name="theme" value="dark" type="submit">
|
|
||||||
Dark mode
|
|
||||||
</NavDropdown.Item>
|
|
||||||
<NavDropdown.Item
|
|
||||||
as="button"
|
|
||||||
name="theme"
|
|
||||||
value="light"
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
Light mode
|
|
||||||
</NavDropdown.Item>
|
|
||||||
</NavDropdown>
|
|
||||||
</fetcher.Form>
|
|
||||||
</Navbar>
|
</Navbar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,18 +25,8 @@ export default function handleRequest(
|
||||||
loadContext: AppLoadContext,
|
loadContext: AppLoadContext,
|
||||||
) {
|
) {
|
||||||
return isbot(request.headers.get("user-agent") || "")
|
return isbot(request.headers.get("user-agent") || "")
|
||||||
? handleBotRequest(
|
? handleBotRequest(request, responseStatusCode, responseHeaders, remixContext)
|
||||||
request,
|
: handleBrowserRequest(request, responseStatusCode, responseHeaders, remixContext);
|
||||||
responseStatusCode,
|
|
||||||
responseHeaders,
|
|
||||||
remixContext,
|
|
||||||
)
|
|
||||||
: handleBrowserRequest(
|
|
||||||
request,
|
|
||||||
responseStatusCode,
|
|
||||||
responseHeaders,
|
|
||||||
remixContext,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBotRequest(
|
function handleBotRequest(
|
||||||
|
@ -48,11 +38,7 @@ function handleBotRequest(
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let shellRendered = false;
|
let shellRendered = false;
|
||||||
const { pipe, abort } = renderToPipeableStream(
|
const { pipe, abort } = renderToPipeableStream(
|
||||||
<RemixServer
|
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
|
||||||
context={remixContext}
|
|
||||||
url={request.url}
|
|
||||||
abortDelay={ABORT_DELAY}
|
|
||||||
/>,
|
|
||||||
{
|
{
|
||||||
onAllReady() {
|
onAllReady() {
|
||||||
shellRendered = true;
|
shellRendered = true;
|
||||||
|
@ -98,11 +84,7 @@ function handleBrowserRequest(
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let shellRendered = false;
|
let shellRendered = false;
|
||||||
const { pipe, abort } = renderToPipeableStream(
|
const { pipe, abort } = renderToPipeableStream(
|
||||||
<RemixServer
|
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
|
||||||
context={remixContext}
|
|
||||||
url={request.url}
|
|
||||||
abortDelay={ABORT_DELAY}
|
|
||||||
/>,
|
|
||||||
{
|
{
|
||||||
onShellReady() {
|
onShellReady() {
|
||||||
shellRendered = true;
|
shellRendered = true;
|
||||||
|
|
|
@ -35,15 +35,11 @@ export default async function serverRequest<T>(
|
||||||
} as ApiError;
|
} as ApiError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp.status < 200 || resp.status >= 400)
|
if (resp.status < 200 || resp.status >= 400) throw (await resp.json()) as ApiError;
|
||||||
throw (await resp.json()) as ApiError;
|
|
||||||
return (await resp.json()) as T;
|
return (await resp.json()) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCookie(
|
export function getCookie(req: Request, cookieName: string): string | undefined {
|
||||||
req: Request,
|
|
||||||
cookieName: string,
|
|
||||||
): string | undefined {
|
|
||||||
const header = req.headers.get("Cookie");
|
const header = req.headers.get("Cookie");
|
||||||
if (!header) return undefined;
|
if (!header) return undefined;
|
||||||
|
|
||||||
|
@ -53,11 +49,7 @@ export function getCookie(
|
||||||
|
|
||||||
const YEAR = 365 * 86400;
|
const YEAR = 365 * 86400;
|
||||||
|
|
||||||
export const writeCookie = (
|
export const writeCookie = (cookieName: string, value: string, maxAge: number | undefined = YEAR) =>
|
||||||
cookieName: string,
|
|
||||||
value: string,
|
|
||||||
maxAge: number | undefined = YEAR,
|
|
||||||
) =>
|
|
||||||
serializeCookie(cookieName, value, {
|
serializeCookie(cookieName, value, {
|
||||||
maxAge,
|
maxAge,
|
||||||
path: "/",
|
path: "/",
|
||||||
|
|
|
@ -32,11 +32,7 @@ export const loader: LoaderFunction = async ({ request }) => {
|
||||||
const user = await serverRequest<User>("GET", "/users/@me", { token });
|
const user = await serverRequest<User>("GET", "/users/@me", { token });
|
||||||
meUser = user;
|
meUser = user;
|
||||||
|
|
||||||
settings = await serverRequest<UserSettings>(
|
settings = await serverRequest<UserSettings>("GET", "/users/@me/settings", { token });
|
||||||
"GET",
|
|
||||||
"/users/@me/settings",
|
|
||||||
{ token },
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// If we get an unauthorized error, clear the token, as it's not valid anymore.
|
// If we get an unauthorized error, clear the token, as it's not valid anymore.
|
||||||
if ((e as ApiError).code === ErrorCode.AuthenticationRequired) {
|
if ((e as ApiError).code === ErrorCode.AuthenticationRequired) {
|
||||||
|
|
|
@ -31,10 +31,7 @@ if (viteDevServer) {
|
||||||
app.use(viteDevServer.middlewares);
|
app.use(viteDevServer.middlewares);
|
||||||
} else {
|
} else {
|
||||||
// Vite fingerprints its assets so we can cache forever.
|
// Vite fingerprints its assets so we can cache forever.
|
||||||
app.use(
|
app.use("/assets", express.static("build/client/assets", { immutable: true, maxAge: "1y" }));
|
||||||
"/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
|
// 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);
|
app.all("*", remixHandler);
|
||||||
|
|
||||||
const port = env.PORT || 3000;
|
const port = env.PORT || 3000;
|
||||||
app.listen(port, () =>
|
app.listen(port, () => console.log(`Express server listening at http://localhost:${port}`));
|
||||||
console.log(`Express server listening at http://localhost:${port}`),
|
|
||||||
);
|
|
||||||
|
|
Loading…
Reference in a new issue