summary refs log tree commit diff
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-01-14 18:39:04 +0100
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-01-14 18:39:04 +0100
commit45432dd9c87ff398de1faf5a0083c366a2ea391b (patch)
tree3de3f02af22ffbf326ae7ed3655fd94a9a6ea52d
parentvar -> let (diff)
downloadserver-45432dd9c87ff398de1faf5a0083c366a2ea391b.tar.xz
Clean up imports dev/rory/versioned-api
Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>
-rw-r--r--.vscode/tasks.json15
-rw-r--r--src/api/Server.ts9
-rw-r--r--src/api/routes/v0/applications/#id/skus.ts1
-rw-r--r--src/api/routes/v9/auth/location-metadata.ts3
-rw-r--r--src/api/routes/v9/channels/#channel_id/messages/index.ts12
-rw-r--r--src/api/routes/v9/channels/#channel_id/webhooks.ts2
-rw-r--r--src/api/routes/v9/guild-recommendations.ts2
-rw-r--r--src/api/routes/v9/guilds/#guild_id/delete.ts12
-rw-r--r--src/api/routes/v9/guilds/#guild_id/discovery-requirements.ts2
-rw-r--r--src/api/routes/v9/guilds/#guild_id/invites.ts2
-rw-r--r--src/api/routes/v9/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts2
-rw-r--r--src/api/routes/v9/guilds/#guild_id/regions.ts5
-rw-r--r--src/api/routes/v9/oauth2/authorize.ts3
-rw-r--r--src/api/routes/v9/users/@me/delete.ts2
-rw-r--r--src/api/routes/v9/users/@me/relationships.ts2
-rw-r--r--src/api/routes/v9/users/@me/settings.ts2
-rw-r--r--src/api/routes/v9/voice/regions.ts3
-rw-r--r--src/gateway/opcodes/Identify.ts6
-rw-r--r--src/util/entities/Team.ts1
-rw-r--r--src/util/entities/User.ts2
20 files changed, 37 insertions, 51 deletions
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 00000000..32a6e4c0
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,15 @@
+{
+	"version": "2.0.0",
+	"tasks": [
+		{
+			"type": "typescript",
+			"tsconfig": "tsconfig.json",
+			"option": "watch",
+			"problemMatcher": [
+				"$tsc-watch"
+			],
+			"group": "build",
+			"label": "tsc: watch - tsconfig.json"
+		}
+	]
+}
\ No newline at end of file
diff --git a/src/api/Server.ts b/src/api/Server.ts
index 088c1953..61fcca81 100644
--- a/src/api/Server.ts
+++ b/src/api/Server.ts
@@ -1,7 +1,13 @@
 import "missing-native-js-functions";
 import { Server, ServerOptions } from "lambert-server";
 import { Authentication, CORS } from "./middlewares/";
-import { Config, initDatabase, initEvent, Sentry } from "@fosscord/util";
+import {
+	Config,
+	initDatabase,
+	initEvent,
+	Sentry,
+	registerRoutes,
+} from "@fosscord/util";
 import { ErrorHandler } from "./middlewares/ErrorHandler";
 import { BodyParser } from "./middlewares/BodyParser";
 import { Router, Request, Response, NextFunction } from "express";
@@ -11,7 +17,6 @@ import TestClient from "./middlewares/TestClient";
 import { initTranslation } from "./middlewares/Translation";
 import morgan from "morgan";
 import { initInstance } from "./util/handlers/Instance";
-import { registerRoutes } from "@fosscord/util";
 import { red } from "picocolors";
 
 export interface FosscordServerOptions extends ServerOptions {}
diff --git a/src/api/routes/v0/applications/#id/skus.ts b/src/api/routes/v0/applications/#id/skus.ts
index 2383e6f7..86e36558 100644
--- a/src/api/routes/v0/applications/#id/skus.ts
+++ b/src/api/routes/v0/applications/#id/skus.ts
@@ -1,6 +1,5 @@
 import { Request, Response, Router } from "express";
 import { route } from "@fosscord/api";
-import { Application, OrmUtils, Team, trimSpecial, User } from "@fosscord/util";
 
 const router: Router = Router();
 
diff --git a/src/api/routes/v9/auth/location-metadata.ts b/src/api/routes/v9/auth/location-metadata.ts
index 0ae946ed..5b86efc8 100644
--- a/src/api/routes/v9/auth/location-metadata.ts
+++ b/src/api/routes/v9/auth/location-metadata.ts
@@ -1,6 +1,5 @@
 import { Router, Request, Response } from "express";
-import { route } from "@fosscord/api";
-import { getIpAdress, IPAnalysis } from "@fosscord/api";
+import { route, getIpAdress, IPAnalysis } from "@fosscord/api";
 const router = Router();
 
 router.get("/", route({}), async (req: Request, res: Response) => {
diff --git a/src/api/routes/v9/channels/#channel_id/messages/index.ts b/src/api/routes/v9/channels/#channel_id/messages/index.ts
index d8c69dd0..c2ff12fd 100644
--- a/src/api/routes/v9/channels/#channel_id/messages/index.ts
+++ b/src/api/routes/v9/channels/#channel_id/messages/index.ts
@@ -2,7 +2,6 @@ import { Router, Response, Request } from "express";
 import {
 	Attachment,
 	Channel,
-	ChannelType,
 	Config,
 	DmChannelDTO,
 	emitEvent,
@@ -13,22 +12,13 @@ import {
 	Snowflake,
 	uploadFile,
 	Member,
-	Role,
 	MessageCreateSchema,
 	ReadState,
-	DiscordApiErrors,
-	getRights,
 	Rights,
 } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import {
-	handleMessage,
-	postHandleMessage,
-	route,
-	getIpAdress,
-} from "@fosscord/api";
+import { handleMessage, postHandleMessage, route } from "@fosscord/api";
 import multer from "multer";
-import { yellow } from "picocolors";
 import { FindManyOptions, LessThan, MoreThan } from "typeorm";
 import { URL } from "url";
 
diff --git a/src/api/routes/v9/channels/#channel_id/webhooks.ts b/src/api/routes/v9/channels/#channel_id/webhooks.ts
index 9af188f0..d786497a 100644
--- a/src/api/routes/v9/channels/#channel_id/webhooks.ts
+++ b/src/api/routes/v9/channels/#channel_id/webhooks.ts
@@ -9,9 +9,9 @@ import {
 	Webhook,
 	WebhookCreateSchema,
 	WebhookType,
+	DiscordApiErrors,
 } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { DiscordApiErrors } from "@fosscord/util";
 import crypto from "crypto";
 
 const router: Router = Router();
diff --git a/src/api/routes/v9/guild-recommendations.ts b/src/api/routes/v9/guild-recommendations.ts
index 8ee7fe66..a7a8040b 100644
--- a/src/api/routes/v9/guild-recommendations.ts
+++ b/src/api/routes/v9/guild-recommendations.ts
@@ -10,7 +10,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
 	const { limit, personalization_disabled } = req.query;
 	let showAllGuilds = Config.get().guild.discovery.showAllGuilds;
 
-	const genLoadId = (size: Number) =>
+	const genLoadId = (size: number) =>
 		[...Array(size)]
 			.map(() => Math.floor(Math.random() * 16).toString(16))
 			.join("");
diff --git a/src/api/routes/v9/guilds/#guild_id/delete.ts b/src/api/routes/v9/guilds/#guild_id/delete.ts
index 2c15e0de..3e9d4ef6 100644
--- a/src/api/routes/v9/guilds/#guild_id/delete.ts
+++ b/src/api/routes/v9/guilds/#guild_id/delete.ts
@@ -1,14 +1,4 @@
-import {
-	Channel,
-	emitEvent,
-	GuildDeleteEvent,
-	Guild,
-	Member,
-	Message,
-	Role,
-	Invite,
-	Emoji,
-} from "@fosscord/util";
+import { emitEvent, GuildDeleteEvent, Guild } from "@fosscord/util";
 import { Router, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
 import { route } from "@fosscord/api";
diff --git a/src/api/routes/v9/guilds/#guild_id/discovery-requirements.ts b/src/api/routes/v9/guilds/#guild_id/discovery-requirements.ts
index 7e63c06b..a7797c83 100644
--- a/src/api/routes/v9/guilds/#guild_id/discovery-requirements.ts
+++ b/src/api/routes/v9/guilds/#guild_id/discovery-requirements.ts
@@ -1,5 +1,3 @@
-import { Guild, Config } from "@fosscord/util";
-
 import { Router, Request, Response } from "express";
 import { route } from "@fosscord/api";
 
diff --git a/src/api/routes/v9/guilds/#guild_id/invites.ts b/src/api/routes/v9/guilds/#guild_id/invites.ts
index 4d033e9c..cdba51b5 100644
--- a/src/api/routes/v9/guilds/#guild_id/invites.ts
+++ b/src/api/routes/v9/guilds/#guild_id/invites.ts
@@ -1,4 +1,4 @@
-import { getPermission, Invite, PublicInviteRelation } from "@fosscord/util";
+import { Invite, PublicInviteRelation } from "@fosscord/util";
 import { route } from "@fosscord/api";
 import { Request, Response, Router } from "express";
 
diff --git a/src/api/routes/v9/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts b/src/api/routes/v9/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
index c0383912..4e80ba21 100644
--- a/src/api/routes/v9/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
+++ b/src/api/routes/v9/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
@@ -1,4 +1,4 @@
-import { getPermission, Member } from "@fosscord/util";
+import { Member } from "@fosscord/util";
 import { route } from "@fosscord/api";
 import { Request, Response, Router } from "express";
 
diff --git a/src/api/routes/v9/guilds/#guild_id/regions.ts b/src/api/routes/v9/guilds/#guild_id/regions.ts
index 0b275ea4..49ec4531 100644
--- a/src/api/routes/v9/guilds/#guild_id/regions.ts
+++ b/src/api/routes/v9/guilds/#guild_id/regions.ts
@@ -1,7 +1,6 @@
-import { Config, Guild, Member } from "@fosscord/util";
+import { Guild } from "@fosscord/util";
 import { Request, Response, Router } from "express";
-import { getVoiceRegions, route } from "@fosscord/api";
-import { getIpAdress } from "@fosscord/api";
+import { getVoiceRegions, route, getIpAdress } from "@fosscord/api";
 
 const router = Router();
 
diff --git a/src/api/routes/v9/oauth2/authorize.ts b/src/api/routes/v9/oauth2/authorize.ts
index 6374972e..779545b6 100644
--- a/src/api/routes/v9/oauth2/authorize.ts
+++ b/src/api/routes/v9/oauth2/authorize.ts
@@ -9,9 +9,6 @@ import {
 	Member,
 	Permissions,
 	User,
-	getRights,
-	Rights,
-	MemberPrivateProjection,
 } from "@fosscord/util";
 const router = Router();
 
diff --git a/src/api/routes/v9/users/@me/delete.ts b/src/api/routes/v9/users/@me/delete.ts
index a9f8167c..e0173d5b 100644
--- a/src/api/routes/v9/users/@me/delete.ts
+++ b/src/api/routes/v9/users/@me/delete.ts
@@ -1,5 +1,5 @@
 import { Router, Request, Response } from "express";
-import { Guild, Member, User } from "@fosscord/util";
+import { Member, User } from "@fosscord/util";
 import { route } from "@fosscord/api";
 import bcrypt from "bcrypt";
 import { HTTPError } from "lambert-server";
diff --git a/src/api/routes/v9/users/@me/relationships.ts b/src/api/routes/v9/users/@me/relationships.ts
index 6b5d429c..318c26d6 100644
--- a/src/api/routes/v9/users/@me/relationships.ts
+++ b/src/api/routes/v9/users/@me/relationships.ts
@@ -7,10 +7,10 @@ import {
 	emitEvent,
 	Relationship,
 	Config,
+	DiscordApiErrors,
 } from "@fosscord/util";
 import { Router, Response, Request } from "express";
 import { HTTPError } from "lambert-server";
-import { DiscordApiErrors } from "@fosscord/util";
 import { route } from "@fosscord/api";
 
 const router = Router();
diff --git a/src/api/routes/v9/users/@me/settings.ts b/src/api/routes/v9/users/@me/settings.ts
index cce366ac..07a237da 100644
--- a/src/api/routes/v9/users/@me/settings.ts
+++ b/src/api/routes/v9/users/@me/settings.ts
@@ -1,5 +1,5 @@
 import { Router, Response, Request } from "express";
-import { OrmUtils, User, UserSettingsSchema } from "@fosscord/util";
+import { User, UserSettingsSchema } from "@fosscord/util";
 import { route } from "@fosscord/api";
 
 const router = Router();
diff --git a/src/api/routes/v9/voice/regions.ts b/src/api/routes/v9/voice/regions.ts
index 4de304ee..c174e98d 100644
--- a/src/api/routes/v9/voice/regions.ts
+++ b/src/api/routes/v9/voice/regions.ts
@@ -1,6 +1,5 @@
 import { Router, Request, Response } from "express";
-import { getIpAdress, route } from "@fosscord/api";
-import { getVoiceRegions } from "@fosscord/api";
+import { getIpAdress, route, getVoiceRegions } from "@fosscord/api";
 
 const router: Router = Router();
 
diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index 2b1bfc3f..c39a0d01 100644
--- a/src/gateway/opcodes/Identify.ts
+++ b/src/gateway/opcodes/Identify.ts
@@ -24,16 +24,14 @@ import {
 	UserGuildSettings,
 	ReadyGuildDTO,
 	Guild,
+	Recipient,
 } from "@fosscord/util";
 import { Send } from "../util/Send";
 import { CLOSECODES, OPCODES } from "../util/Constants";
-import { genSessionId } from "../util/SessionUtils";
 import { setupListener } from "../listener/listener";
 // import experiments from "./experiments.json";
 const experiments: any = [];
 import { check } from "./instanceOf";
-import { Recipient } from "@fosscord/util";
-
 // TODO: user sharding
 // TODO: check privileged intents, if defined in the config
 // TODO: check if already identified
@@ -50,11 +48,11 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 	try {
 		const { jwtSecret } = Config.get().security;
 		let { decoded } = await checkToken(identify.token, jwtSecret); // will throw an error if invalid
+		this.user_id = decoded.id;
 	} catch (error) {
 		console.error("invalid token", error);
 		return this.close(CLOSECODES.Authentication_failed);
 	}
-	this.user_id = decoded.id;
 	let session_id = this.session_id;
 
 	const [user, read_states, members, recipients, session, application] =
diff --git a/src/util/entities/Team.ts b/src/util/entities/Team.ts
index 8f410bb4..6014f044 100644
--- a/src/util/entities/Team.ts
+++ b/src/util/entities/Team.ts
@@ -2,7 +2,6 @@ import {
 	Column,
 	Entity,
 	JoinColumn,
-	ManyToMany,
 	ManyToOne,
 	OneToMany,
 	RelationId,
diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index e8b724be..1f75da9d 100644
--- a/src/util/entities/User.ts
+++ b/src/util/entities/User.ts
@@ -1,6 +1,4 @@
 import {
-	BeforeInsert,
-	BeforeUpdate,
 	Column,
 	Entity,
 	FindOneOptions,