diff --git a/benchmarks/posting.ts b/benchmarks/posting.ts index f3e90d46..8337712e 100644 --- a/benchmarks/posting.ts +++ b/benchmarks/posting.ts @@ -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`); +// diff --git a/bun.lockb b/bun.lockb index 5b0e9d77..2eeae632 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 10dbb32b..f05d49b0 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,9 @@ "dev": "bun run index.ts", "start": "bun run index.ts", "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": [ "sharp", @@ -64,7 +66,7 @@ }, "dependencies": { "@aws-sdk/client-s3": "^3.429.0", - "@prisma/client": "^5.5.2", + "@prisma/client": "^5.6.0", "chalk": "^5.3.0", "html-to-text": "^9.0.5", "ip-matching": "^2.1.2", @@ -73,7 +75,7 @@ "jsonld": "^8.3.1", "marked": "^9.1.2", "pg": "^8.11.3", - "prisma": "^5.5.2", + "prisma": "latest", "reflect-metadata": "^0.1.13", "sharp": "^0.32.6", "typeorm": "^0.3.17" diff --git a/types/entities/identity_proof.ts b/types/entities/identity_proof.ts index 513925ff..5964723e 100644 --- a/types/entities/identity_proof.ts +++ b/types/entities/identity_proof.ts @@ -4,4 +4,4 @@ export interface APIIdentityProof { updated_at: string; proof_url: string; profile_url: string; -} \ No newline at end of file +} diff --git a/types/lysand/extensions/org.lysand/reactions.ts b/types/lysand/extensions/org.lysand/reactions.ts index b18d5256..8830ea1f 100644 --- a/types/lysand/extensions/org.lysand/reactions.ts +++ b/types/lysand/extensions/org.lysand/reactions.ts @@ -1,8 +1,8 @@ import { ExtensionType } from "../../Extension"; export interface OrgLysandReactionsType extends ExtensionType { - extension_type: "org.lysand:reactions/Reaction"; - author: string; - object: string; - content: string; -} \ No newline at end of file + extension_type: "org.lysand:reactions/Reaction"; + author: string; + object: string; + content: string; +}