summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 11:03:32 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-10 11:03:32 +0200
commit74bd98737acf89d9d56ee66a68694d82f591d591 (patch)
treeb93c79b510a962316fb14a125cac6e177e600c53 /api/src
parent:art: clean up dependencies (diff)
downloadserver-74bd98737acf89d9d56ee66a68694d82f591d591.tar.xz
:art: clean up imports + classes
Diffstat (limited to 'api/src')
-rw-r--r--api/src/Server.ts3
-rw-r--r--api/src/routes/channels/#channel_id/invites.ts2
-rw-r--r--api/src/routes/channels/#channel_id/messages/index.ts3
-rw-r--r--api/src/test/jwt.ts37
-rw-r--r--api/src/test/jwt2.ts13
-rw-r--r--api/src/test/password_test.ts12
6 files changed, 2 insertions, 68 deletions
diff --git a/api/src/Server.ts b/api/src/Server.ts
index 12c1d6b4..19e3d245 100644
--- a/api/src/Server.ts
+++ b/api/src/Server.ts
@@ -1,13 +1,10 @@
-import { OptionsJson } from "body-parser";
 import "missing-native-js-functions";
-import { Connection } from "mongoose";
 import { Server, ServerOptions } from "lambert-server";
 import { Authentication, CORS } from "./middlewares/";
 import { Config, initDatabase, initEvent } from "@fosscord/util";
 import { ErrorHandler } from "./middlewares/ErrorHandler";
 import { BodyParser } from "./middlewares/BodyParser";
 import { Router, Request, Response, NextFunction } from "express";
-import mongoose from "mongoose";
 import path from "path";
 import { initRateLimits } from "./middlewares/RateLimit";
 import TestClient from "./middlewares/TestClient";
diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts
index 22420983..6d2c625d 100644
--- a/api/src/routes/channels/#channel_id/invites.ts
+++ b/api/src/routes/channels/#channel_id/invites.ts
@@ -2,7 +2,7 @@ import { Router, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
 import { route } from "@fosscord/api";
 import { random } from "@fosscord/api";
-import { getPermission, Channel, Invite, InviteCreateEvent, emitEvent, User, Guild, PublicInviteRelation } from "@fosscord/util";
+import { Channel, Invite, InviteCreateEvent, emitEvent, User, Guild, PublicInviteRelation } from "@fosscord/util";
 import { isTextChannel } from "./messages";
 
 const router: Router = Router();
diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts
index 4ec31417..26bb9e5d 100644
--- a/api/src/routes/channels/#channel_id/messages/index.ts
+++ b/api/src/routes/channels/#channel_id/messages/index.ts
@@ -22,7 +22,7 @@ const router: Router = Router();
 
 export default router;
 
-function isTextChannel(type: ChannelType): boolean {
+export function isTextChannel(type: ChannelType): boolean {
 	switch (type) {
 		case ChannelType.GUILD_STORE:
 		case ChannelType.GUILD_VOICE:
@@ -39,7 +39,6 @@ function isTextChannel(type: ChannelType): boolean {
 			return true;
 	}
 }
-module.exports.isTextChannel = isTextChannel;
 
 export interface MessageCreateSchema {
 	content?: string;
diff --git a/api/src/test/jwt.ts b/api/src/test/jwt.ts
deleted file mode 100644
index bdad513b..00000000
--- a/api/src/test/jwt.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-const jwa = require("jwa");
-
-var STR64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split("");
-
-function base64url(string: string, encoding: string) {
-	// @ts-ignore
-	return Buffer.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
-}
-
-function to64String(input: number, current = ""): string {
-	if (input < 0 && current.length == 0) {
-		input = input * -1;
-	}
-	var modify = input % 64;
-	var remain = Math.floor(input / 64);
-	var result = STR64[modify] + current;
-	return remain <= 0 ? result : to64String(remain, result);
-}
-
-function to64Parse(input: string) {
-	var result = 0;
-	var toProc = input.split("");
-	var e;
-	for (e in toProc) {
-		result = result * 64 + STR64.indexOf(toProc[e]);
-	}
-	return result;
-}
-
-// @ts-ignore
-const start = `${base64url("311129357362135041")}.${to64String(Date.now())}`;
-const signature = jwa("HS256").sign(start, `test`);
-const token = `${start}.${signature}`;
-console.log(token);
-
-// MzExMTI5MzU3MzYyMTM1MDQx.XdQb_rA.907VgF60kocnOTl32MSUWGSSzbAytQ0jbt36KjLaxuY
-// MzExMTI5MzU3MzYyMTM1MDQx.XdQbaPy.4vGx4L7IuFJGsRe6IL3BeybLIvbx4Vauvx12pwNsy2U
diff --git a/api/src/test/jwt2.ts b/api/src/test/jwt2.ts
deleted file mode 100644
index e231233d..00000000
--- a/api/src/test/jwt2.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import jwt from "jsonwebtoken";
-
-const algorithm = "HS256";
-const iat = Math.floor(Date.now() / 1000);
-
-// @ts-ignore
-const token = jwt.sign({ id: "311129357362135041" }, "secret", {
-	algorithm,
-});
-console.log(token);
-
-const decoded = jwt.verify(token, "secret", { algorithms: [algorithm] });
-console.log(decoded);
diff --git a/api/src/test/password_test.ts b/api/src/test/password_test.ts
deleted file mode 100644
index 983b18ae..00000000
--- a/api/src/test/password_test.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { checkPassword } from "@fosscord/api";
-
-console.log(checkPassword("123456789012345"));
-// -> 0.25
-console.log(checkPassword("ABCDEFGHIJKLMOPQ"));
-// -> 0.25
-console.log(checkPassword("ABC123___...123"));
-// ->
-console.log(checkPassword(""));
-// ->
-// console.log(checkPassword(""));
-// // ->