refactor: ⚰️ Remove dead code and useless files

This commit is contained in:
Jesse Wierzbinski 2024-06-12 20:34:17 -10:00
parent 98f3ab23d8
commit 83275be536
No known key found for this signature in database
14 changed files with 3 additions and 185 deletions

View file

@ -24,7 +24,6 @@ import { objectToInboxRequest } from "~/database/entities/federation";
import { addInstanceIfNotExists } from "~/database/entities/instance";
import {
type UserWithRelations,
findFirstUser,
findManyUsers,
} from "~/database/entities/user";
import { db } from "~/drizzle/db";
@ -75,15 +74,15 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
sql: SQL<unknown> | undefined,
orderBy: SQL<unknown> | undefined = desc(Users.id),
) {
const found = await findFirstUser({
const found = await findManyUsers({
where: sql,
orderBy,
});
if (!found) {
if (!found[0]) {
return null;
}
return new User(found);
return new User(found[0]);
}
static async manyFromSql(

View file

@ -226,66 +226,6 @@ export class LogManager {
}
await this.log(LogLevel.Info, "Request", string);
}
/*
* Logs a request to the output
* @param req Request to log
* @param ip IP of the request
* @param logAllDetails Whether to log all details of the request
*/
/**async logRequest(req: Request, ip?: string, logAllDetails = false) {
let string = ip ? `${ip}: ` : "";
string += `${req.method} ${req.url}`;
if (logAllDetails) {
string += "\n";
string += " [Headers]\n";
// Pretty print headers
for (const [key, value] of req.headers.entries()) {
string += ` ${key}: ${value}\n`;
}
// Pretty print body
string += " [Body]\n";
const contentType = req.headers.get("Content-Type");
if (contentType?.includes("application/json")) {
try {
const json = await req.clone().json();
const stringified = JSON.stringify(json, null, 4)
.split("\n")
.map((line) => ` ${line}`)
.join("\n");
string += `${stringified}\n`;
} catch {
string += ` [Invalid JSON] (raw: ${await req
.clone()
.text()})\n`;
}
} else if (
contentType &&
(contentType.includes("application/x-www-form-urlencoded") ||
contentType.includes("multipart/form-data"))
) {
const formData = await req.clone().formData();
for (const [key, value] of formData.entries()) {
if (value.toString().length < 300) {
string += ` ${key}: ${value.toString()}\n`;
} else {
string += ` ${key}: <${
value.toString().length
} bytes>\n`;
}
}
} else {
const text = await req.text();
string += ` ${text}\n`;
}
}
await this.log(LogLevel.Info, "Request", string);
} */
}
/**