From e9d55ff44b46f9a4fd52ecf2b3671234cbaede1b Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 13 Feb 2023 11:17:07 -0800 Subject: [PATCH] chore: formatting --- packages/backend/src/server/api/index.ts | 4 ++-- .../src/server/api/mastodon/endpoints/account.ts | 11 +++++++---- .../src/server/api/mastodon/endpoints/timeline.ts | 10 +++++----- packages/backend/src/server/index.ts | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index bc1f94a7c5..3ea3ff67e7 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -71,9 +71,9 @@ mastoRouter.use( mastoRouter.use(async (ctx, next) => { if (ctx.request.query) { if (!ctx.request.body || Object.keys(ctx.request.body).length === 0) { - ctx.request.body = ctx.request.query + ctx.request.body = ctx.request.query; } else { - ctx.request.body = {...ctx.request.body, ...ctx.request.query} + ctx.request.body = { ...ctx.request.body, ...ctx.request.query }; } } await next(); diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index 21bb4a6fbb..7a3df03bdb 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -75,18 +75,21 @@ export function apiAccountMastodon(router: Router): void { let userid; if (userArray === undefined) { ctx.status = 401; - ctx.body = { error: "no user specified"}; + ctx.body = { error: "no user specified" }; return; } if (userArray.length === 1) { - const q: FindOptionsWhere = { usernameLower: userArray[0].toLowerCase(), host: IsNull() }; + const q: FindOptionsWhere = { + usernameLower: userArray[0].toLowerCase(), + host: IsNull(), + }; const user = await Users.findOneBy(q); userid = user?.id; } else { userid = (await resolveUser(userArray[0], userArray[1])).id; } - const data = await client.getAccount(userid ? userid : ''); + const data = await client.getAccount(userid ? userid : ""); ctx.body = data.data; } catch (e: any) { console.error(e); @@ -311,7 +314,7 @@ export function apiAccountMastodon(router: Router): void { } catch (e: any) { console.error(e); console.error(e.response.data); - e.response.data.user = users ? users : 'null'; + e.response.data.user = users ? users : "null"; ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts index 04a15e65df..7cd9e26cb8 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts @@ -15,9 +15,11 @@ export function limitToInt(q: ParsedUrlQuery) { export function argsToBools(q: ParsedUrlQuery) { let object: any = q; if (q.only_media) - if (typeof q.only_media === "string") object.only_media = q.only_media.toLowerCase() === "true"; + if (typeof q.only_media === "string") + object.only_media = q.only_media.toLowerCase() === "true"; if (q.exclude_replies) - if (typeof q.exclude_replies === "string") object.exclude_replies = q.exclude_replies.toLowerCase() === "true"; + if (typeof q.exclude_replies === "string") + object.exclude_replies = q.exclude_replies.toLowerCase() === "true"; return q; } @@ -143,9 +145,7 @@ export function apiTimelineMastodon(router: Router): void { const accessTokens = ctx.headers.authorization; const client = getClient(BASE_URL, accessTokens); try { - const data = await client.getConversationTimeline( - limitToInt(ctx.query), - ); + const data = await client.getConversationTimeline(limitToInt(ctx.query)); ctx.body = data.data; } catch (e: any) { console.error(e); diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 73cf58ec27..6dff706653 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -81,9 +81,9 @@ mastoRouter.use( mastoRouter.use(async (ctx, next) => { if (ctx.request.query) { if (!ctx.request.body || Object.keys(ctx.request.body).length === 0) { - ctx.request.body = ctx.request.query + ctx.request.body = ctx.request.query; } else { - ctx.request.body = {...ctx.request.body, ...ctx.request.query} + ctx.request.body = { ...ctx.request.body, ...ctx.request.query }; } } await next();