Prettier 8

This commit is contained in:
Rory&
2025-12-17 07:54:46 +01:00
parent f6b440301c
commit 073bf7e0eb
8 changed files with 13 additions and 51 deletions
@@ -19,7 +19,7 @@
import { route } from "@spacebar/api";
import { User } from "@spacebar/util";
import { Request, Response, Router } from "express";
import { UserRelationsResponse } from "@spacebar/schemas"
import { UserRelationsResponse } from "@spacebar/schemas";
const router: Router = Router({ mergeParams: true });
@@ -47,11 +47,7 @@ router.get(
for (const rmem of requested_relations.relationships) {
for (const smem of self_relations.relationships)
if (
rmem.to_id === smem.to_id &&
rmem.type === 1 &&
rmem.to_id !== req.user_id
) {
if (rmem.to_id === smem.to_id && rmem.type === 1 && rmem.to_id !== req.user_id) {
const relation_user = await User.getPublicUser(rmem.to_id);
mutual_relations.push({
@@ -17,13 +17,9 @@
*/
import { route } from "@spacebar/api";
import {
Channel,
Member,
OrmUtils,
} from "@spacebar/util";
import { Channel, Member, OrmUtils } from "@spacebar/util";
import { Request, Response, Router } from "express";
import { UserGuildSettingsSchema } from "@spacebar/schemas"
import { UserGuildSettingsSchema } from "@spacebar/schemas";
const router = Router({ mergeParams: true });
+1 -7
View File
@@ -20,13 +20,7 @@ import { Request } from "express";
import { ntob } from "./Base64";
import { FieldErrors, Random } from "@spacebar/util";
export function checkLength(
str: string,
min: number,
max: number,
key: string,
req: Request,
) {
export function checkLength(str: string, min: number, max: number, key: string, req: Request) {
if (str.length < min || str.length > max) {
throw FieldErrors({
[key]: {
@@ -30,17 +30,13 @@ export abstract class RefreshableConnection extends Connection {
* Refreshes the token for a connected account.
* @param connectedAccount The connected account to refresh
*/
abstract refreshToken(
connectedAccount: ConnectedAccount,
): Promise<ConnectedAccountCommonOAuthTokenResponse>;
abstract refreshToken(connectedAccount: ConnectedAccount): Promise<ConnectedAccountCommonOAuthTokenResponse>;
/**
* Refreshes the token for a connected account and saves it to the database.
* @param connectedAccount The connected account to refresh
*/
async refresh(
connectedAccount: ConnectedAccount,
): Promise<ConnectedAccountCommonOAuthTokenResponse> {
async refresh(connectedAccount: ConnectedAccount): Promise<ConnectedAccountCommonOAuthTokenResponse> {
const tokenData = await this.refreshToken(connectedAccount);
connectedAccount.token_data = { ...tokenData, fetched_at: Date.now() };
await connectedAccount.save();
+1 -7
View File
@@ -1,10 +1,4 @@
import {
Column,
Entity,
JoinColumn,
ManyToOne,
RelationId,
} from "typeorm";
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { User } from "./User";
import { Channel } from "./Channel";
+1 -7
View File
@@ -1,10 +1,4 @@
import {
Column,
Entity,
JoinColumn,
ManyToOne,
RelationId,
} from "typeorm";
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { User } from "./User";
import { Stream } from "./Stream";
+2 -6
View File
@@ -18,9 +18,7 @@ export class Snowflake {
static workerId = BigInt((cluster.worker?.id || 0) % 31); // max 31
constructor() {
throw new Error(
`The ${this.constructor.name} class may not be instantiated.`,
);
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
}
/**
@@ -115,9 +113,7 @@ export class Snowflake {
* @returns {DeconstructedSnowflake} Deconstructed snowflake
*/
static deconstruct(snowflake) {
const BINARY = Snowflake.idToBinary(snowflake)
.toString(2)
.padStart(64, "0");
const BINARY = Snowflake.idToBinary(snowflake).toString(2).padStart(64, "0");
const res = {
timestamp: parseInt(BINARY.substring(0, 42), 2) + Snowflake.EPOCH,
workerID: parseInt(BINARY.substring(42, 47), 2),
+2 -6
View File
@@ -19,14 +19,10 @@
import { Server, traverseDirectory } from "lambert-server";
//if we're using ts-node, use ts files instead of js
const extension =
Symbol.for("ts-node.register.instance") in process ? "ts" : "js";
const extension = Symbol.for("ts-node.register.instance") in process ? "ts" : "js";
const DEFAULT_FILTER = new RegExp("^([^.].*)(?<!\\.d).(" + extension + ")$");
export function registerRoutes(server: Server, root: string) {
return traverseDirectory(
{ dirname: root, recursive: true, filter: DEFAULT_FILTER },
server.registerRoute.bind(server, root),
);
return traverseDirectory({ dirname: root, recursive: true, filter: DEFAULT_FILTER }, server.registerRoute.bind(server, root));
}