Fix ESLint errors

This commit is contained in:
Jesse Wierzbinski 2023-11-19 16:25:41 -10:00
parent 103115efa1
commit 1ed3fb474e
5 changed files with 12 additions and 101 deletions

View file

@ -1,92 +1 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ //
/* eslint-disable @typescript-eslint/no-explicit-any */
import { getConfig } from "@config";
import { AppDataSource } from "~database/datasource";
import { ApplicationAction } from "~database/entities/Application";
import { RawActivity } from "~database/entities/RawActivity";
import { Token, TokenType } from "~database/entities/Token";
import { UserAction } from "~database/entities/User";
const config = getConfig();
let token: Token;
if (!AppDataSource.isInitialized) await AppDataSource.initialize();
// Initialize test user
const user = await UserAction.createNewLocal({
email: "test@test.com",
username: "test",
password: "test",
display_name: "",
});
const app = new ApplicationAction();
app.name = "Test Application";
app.website = "https://example.com";
app.client_id = "test";
app.redirect_uris = "https://example.com";
app.scopes = "read write";
app.secret = "test";
app.vapid_key = null;
await app.save();
// Initialize test token
token = new Token();
token.access_token = "test";
token.application = app;
token.code = "test";
token.scope = "read write";
token.token_type = TokenType.BEARER;
token.user = user;
token = await token.save();
await fetch(`${config.http.base_url}/api/v1/statuses`, {
method: "POST",
headers: {
Authorization: `Bearer ${token.access_token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
status: "Hello, world!",
visibility: "public",
}),
});
const timeBefore = performance.now();
// Repeat 100 times
for (let i = 0; i < 100; i++) {
await fetch(`${config.http.base_url}/api/v1/timelines/public`, {
method: "GET",
headers: {
Authorization: `Bearer ${token.access_token}`,
},
});
}
const timeAfter = performance.now();
const activities = await RawActivity.createQueryBuilder("activity")
.where("activity.data->>'actor' = :actor", {
actor: `${config.http.base_url}/users/test`,
})
.leftJoinAndSelect("activity.objects", "objects")
.getMany();
// Delete all created objects and activities as part of testing
await Promise.all(
activities.map(async activity => {
await Promise.all(
activity.objects.map(async object => await object.remove())
);
await activity.remove();
})
);
await user.remove();
console.log(`Time taken: ${timeAfter - timeBefore}ms`);

BIN
bun.lockb

Binary file not shown.

View file

@ -35,7 +35,9 @@
"dev": "bun run index.ts", "dev": "bun run index.ts",
"start": "bun run index.ts", "start": "bun run index.ts",
"migrate-dev": "bunx prisma migrate dev", "migrate-dev": "bunx prisma migrate dev",
"migrate": "bunx prisma migrate deploy" "migrate": "bunx prisma migrate deploy",
"lint": "eslint --config .eslintrc.cjs --ext .ts .",
"generate": "bunx prisma generate"
}, },
"trustedDependencies": [ "trustedDependencies": [
"sharp", "sharp",
@ -64,7 +66,7 @@
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.429.0", "@aws-sdk/client-s3": "^3.429.0",
"@prisma/client": "^5.5.2", "@prisma/client": "^5.6.0",
"chalk": "^5.3.0", "chalk": "^5.3.0",
"html-to-text": "^9.0.5", "html-to-text": "^9.0.5",
"ip-matching": "^2.1.2", "ip-matching": "^2.1.2",
@ -73,7 +75,7 @@
"jsonld": "^8.3.1", "jsonld": "^8.3.1",
"marked": "^9.1.2", "marked": "^9.1.2",
"pg": "^8.11.3", "pg": "^8.11.3",
"prisma": "^5.5.2", "prisma": "latest",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"sharp": "^0.32.6", "sharp": "^0.32.6",
"typeorm": "^0.3.17" "typeorm": "^0.3.17"

View file

@ -4,4 +4,4 @@ export interface APIIdentityProof {
updated_at: string; updated_at: string;
proof_url: string; proof_url: string;
profile_url: string; profile_url: string;
} }

View file

@ -1,8 +1,8 @@
import { ExtensionType } from "../../Extension"; import { ExtensionType } from "../../Extension";
export interface OrgLysandReactionsType extends ExtensionType { export interface OrgLysandReactionsType extends ExtensionType {
extension_type: "org.lysand:reactions/Reaction"; extension_type: "org.lysand:reactions/Reaction";
author: string; author: string;
object: string; object: string;
content: string; content: string;
} }