summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/.github/FUNDING.yml1
-rw-r--r--api/.github/ISSUE_TEMPLATE/-feature--.md20
-rw-r--r--api/.github/workflows/codeql-analysis.yml71
-rw-r--r--api/.github/workflows/docker-publish.yml47
-rw-r--r--api/.github/workflows/release.yml88
-rw-r--r--api/package-lock.json27
-rw-r--r--api/package.json4
-rw-r--r--api/src/Server.ts8
-rw-r--r--api/src/index.ts2
-rw-r--r--api/src/middlewares/Authentication.ts21
-rw-r--r--api/src/middlewares/ErrorHandler.ts2
-rw-r--r--api/src/middlewares/RateLimit.ts21
-rw-r--r--api/src/routes/auth/login.ts2
-rw-r--r--api/src/routes/auth/register.ts2
-rw-r--r--api/src/routes/channels/#channel_id/index.ts3
-rw-r--r--api/src/routes/channels/#channel_id/invites.ts3
-rw-r--r--api/src/routes/channels/#channel_id/messages/#message_id/ack.ts4
-rw-r--r--api/src/routes/channels/#channel_id/messages/#message_id/index.ts4
-rw-r--r--api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts4
-rw-r--r--api/src/routes/channels/#channel_id/messages/bulk-delete.ts4
-rw-r--r--api/src/routes/channels/#channel_id/messages/index.ts2
-rw-r--r--api/src/routes/channels/#channel_id/permissions.ts12
-rw-r--r--api/src/routes/channels/#channel_id/pins.ts4
-rw-r--r--api/src/routes/channels/#channel_id/typing.ts3
-rw-r--r--api/src/routes/channels/#channel_id/webhooks.ts2
-rw-r--r--api/src/routes/gateway.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/bans.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/channels.ts9
-rw-r--r--api/src/routes/guilds/#guild_id/delete.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/index.ts5
-rw-r--r--api/src/routes/guilds/#guild_id/invites.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/index.ts6
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/nick.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/members/index.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/regions.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/roles.ts7
-rw-r--r--api/src/routes/guilds/#guild_id/templates.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/vanity-url.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/welcome_screen.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/widget.json.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/widget.png.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/widget.ts2
-rw-r--r--api/src/routes/guilds/index.ts2
-rw-r--r--api/src/routes/guilds/templates/index.ts2
-rw-r--r--api/src/routes/invites/index.ts2
-rw-r--r--api/src/routes/users/@me/channels.ts7
-rw-r--r--api/src/routes/users/@me/delete.ts2
-rw-r--r--api/src/routes/users/@me/disable.ts2
-rw-r--r--api/src/routes/users/@me/guilds.ts14
-rw-r--r--api/src/routes/users/@me/index.ts2
-rw-r--r--api/src/routes/users/@me/relationships.ts7
-rw-r--r--api/src/schema/Channel.ts2
-rw-r--r--api/src/schema/Guild.ts2
-rw-r--r--api/src/schema/Message.ts2
-rw-r--r--api/src/test/test.ts2
-rw-r--r--api/src/util/Channel.ts8
-rw-r--r--api/src/util/Config.ts4
-rw-r--r--api/src/util/Event.ts26
-rw-r--r--api/src/util/Member.ts7
-rw-r--r--api/src/util/Message.ts16
-rw-r--r--api/src/util/User.ts2
-rw-r--r--api/src/util/cdn.ts2
-rw-r--r--api/src/util/ipAddress.ts2
-rw-r--r--api/src/util/passwordStrength.ts2
65 files changed, 163 insertions, 378 deletions
diff --git a/api/.github/FUNDING.yml b/api/.github/FUNDING.yml
deleted file mode 100644
index f76b9015..00000000
--- a/api/.github/FUNDING.yml
+++ /dev/null
@@ -1 +0,0 @@
-open_collective: fosscord
\ No newline at end of file
diff --git a/api/.github/ISSUE_TEMPLATE/-feature--.md b/api/.github/ISSUE_TEMPLATE/-feature--.md
deleted file mode 100644
index cefcf6b6..00000000
--- a/api/.github/ISSUE_TEMPLATE/-feature--.md
+++ /dev/null
@@ -1,20 +0,0 @@
----
-name: "[Feature] "
-about: Suggest an idea for this project
-title: ''
-labels: enhancement
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
diff --git a/api/.github/workflows/codeql-analysis.yml b/api/.github/workflows/codeql-analysis.yml
deleted file mode 100644
index 3a3a8e92..00000000
--- a/api/.github/workflows/codeql-analysis.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-# For most projects, this workflow file will not need changing; you simply need
-# to commit it to your repository.
-#
-# You may wish to alter this file to override the set of languages analyzed,
-# or to provide custom queries or build logic.
-#
-# ******** NOTE ********
-# We have attempted to detect the languages in your repository. Please check
-# the `language` matrix defined below to confirm you have the correct set of
-# supported CodeQL languages.
-#
-name: "CodeQL"
-
-on:
-  push:
-    branches: [ master ]
-  pull_request:
-    # The branches below must be a subset of the branches above
-    branches: [ master ]
-  schedule:
-    - cron: '25 10 * * 5'
-
-jobs:
-  analyze:
-    name: Analyze
-    runs-on: ubuntu-latest
-    permissions:
-      actions: read
-      contents: read
-      security-events: write
-
-    strategy:
-      fail-fast: false
-      matrix:
-        language: [ 'javascript' ]
-        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
-        # Learn more:
-        # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
-
-    steps:
-    - name: Checkout repository
-      uses: actions/checkout@v2
-
-    # Initializes the CodeQL tools for scanning.
-    - name: Initialize CodeQL
-      uses: github/codeql-action/init@v1
-      with:
-        languages: ${{ matrix.language }}
-        # If you wish to specify custom queries, you can do so here or in a config file.
-        # By default, queries listed here will override any specified in a config file.
-        # Prefix the list here with "+" to use these queries and those in the config file.
-        # queries: ./path/to/local/query, your-org/your-repo/queries@main
-
-    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
-    # If this step fails, then you should remove it and run the build manually (see below)
-    - name: Autobuild
-      uses: github/codeql-action/autobuild@v1
-
-    # ℹī¸ Command-line programs to run using the OS shell.
-    # 📚 https://git.io/JvXDl
-
-    # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines
-    #    and modify them (or add more) to build your code if your project
-    #    uses a compiled language
-
-    #- run: |
-    #   make bootstrap
-    #   make release
-
-    - name: Perform CodeQL Analysis
-      uses: github/codeql-action/analyze@v1
diff --git a/api/.github/workflows/docker-publish.yml b/api/.github/workflows/docker-publish.yml
deleted file mode 100644
index 46d9d04d..00000000
--- a/api/.github/workflows/docker-publish.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-name: docker-publish
-
-on:
-  push:
-    branches:
-      - 'master'
-
-jobs:
-  docker:
-    runs-on: ubuntu-latest
-    steps:
-      -
-        name: Checkout
-        uses: actions/checkout@v2
-      -
-        name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v1
-      -
-        name: Cache Docker layers
-        uses: actions/cache@v2
-        with:
-          path: /tmp/.buildx-cache
-          key: ${{ runner.os }}-buildx-${{ github.sha }}
-          restore-keys: |
-            ${{ runner.os }}-buildx-
-      -
-        name: Login to DockerHub
-        uses: docker/login-action@v1
-        with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
-          password: ${{ secrets.DOCKERHUB_TOKEN }}
-      -
-        name: Build and push
-        uses: docker/build-push-action@v2
-        with:
-          context: .
-          push: true
-          tags: ${{ secrets.DOCKERHUB_TAGS }}
-          cache-from: type=local,src=/tmp/.buildx-cache
-          cache-to: type=local,dest=/tmp/.buildx-cache-new
-      -
-        # Hackfix to cleanup cache; replace after buildx 0.6 and BuildKit 0.9 are released
-        # https://github.com/docker/build-push-action/pull/406#issuecomment-879184394
-        name: Move cache fix
-        run: |
-          rm -rf /tmp/.buildx-cache
-          mv /tmp/.buildx-cache-new /tmp/.buildx-cache
diff --git a/api/.github/workflows/release.yml b/api/.github/workflows/release.yml
deleted file mode 100644
index 3ef40aeb..00000000
--- a/api/.github/workflows/release.yml
+++ /dev/null
@@ -1,88 +0,0 @@
-on:
-  workflow_dispatch:
-  push:
-    # Sequence of patterns matched against refs/tags
-    tags:
-      - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
-
-name: Publish Release
-
-jobs:
-  insiders-build:
-    strategy:
-      matrix:
-        os: [windows, macos, ubuntu]
-        include:
-          - os: windows
-            build: npm run bundle:windows
-            artifact: fosscord-api-windows.exe
-          - os: macos
-            build: npm run bundle:macos
-            artifact: fosscord-api-macos.app.tgz
-          - os: ubuntu
-            build: npm run bundle:linux
-            artifact: fosscord-api-linux.tgz
-    runs-on: ${{ matrix.os }}-latest
-    steps:
-      - uses: actions/checkout@v2
-      - uses: actions/setup-node@v2
-        with:
-          node-version: 14
-      - run: npm install
-      - run: npm run build
-      - run: ${{ matrix.build }}
-      - uses: actions/upload-artifact@v2
-        with:
-          name: ${{ matrix.artifact }}
-          path: ${{ matrix.artifact }}
-
-  release:
-    needs: [insiders-build]
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - name: Extract version
-        id: extract_version
-        uses: Saionaro/extract-package-version@v1.0.6
-      - uses: actions/download-artifact@v2
-        with:
-          name: fosscord-api-windows-${{ github.sha }}.exe
-      - uses: actions/download-artifact@v2
-        with:
-          name: fosscord-api-macos-${{ github.sha }}.app.tgz
-      - uses: actions/download-artifact@v2
-        with:
-          name: fosscord-api-linux-${{ github.sha }}.tgz
-      - uses: actions/create-release@v1
-        id: create-release
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          tag_name: v${{ steps.extract_version.outputs.version }}
-          release_name: Release ${{ steps.extract_version.outputs.version }}
-          draft: false
-          prerelease: true # TODO: change this to false
-      - uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create-release.outputs.upload_url }}
-          asset_path: fosscord-api-windows-${{ github.sha }}.exe
-          asset_name: fosscord-api-windows.exe
-          asset_content_type: application/vnd.microsoft.portable-executable
-      - uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create-release.outputs.upload_url }}
-          asset_path: fosscord-api-macos-${{ github.sha }}.app.tgz
-          asset_name: fosscord-api-macos.app.tgz
-          asset_content_type: application/gzip
-      - uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create-release.outputs.upload_url }}
-          asset_path: fosscord-api-linux-${{ github.sha }}.tgz
-          asset_name: fosscord-api-linux.tgz
-          asset_content_type: application/gzip
diff --git a/api/package-lock.json b/api/package-lock.json
index e4cf20be..c030e642 100644
--- a/api/package-lock.json
+++ b/api/package-lock.json
@@ -6,9 +6,10 @@
 	"packages": {
 		"": {
 			"version": "1.0.0",
+			"hasInstallScript": true,
 			"license": "ISC",
 			"dependencies": {
-				"@fosscord/server-util": "file:../util",
+				"@fosscord/util": "file:../util",
 				"@types/jest": "^26.0.22",
 				"@types/json-schema": "^7.0.7",
 				"ajv": "^8.4.0",
@@ -705,6 +706,10 @@
 			"resolved": "../util",
 			"link": true
 		},
+		"node_modules/@fosscord/util": {
+			"resolved": "../util",
+			"link": true
+		},
 		"node_modules/@istanbuljs/load-nyc-config": {
 			"version": "1.1.0",
 			"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
@@ -12031,6 +12036,26 @@
 				"typescript": "^4.1.3"
 			}
 		},
+		"@fosscord/util": {
+			"version": "file:../util",
+			"requires": {
+				"@types/amqplib": "^0.8.1",
+				"@types/jsonwebtoken": "^8.5.0",
+				"@types/mongoose-autopopulate": "^0.10.1",
+				"@types/mongoose-lean-virtuals": "^0.5.1",
+				"@types/node": "^14.14.25",
+				"ajv": "^8.5.0",
+				"amqplib": "^0.8.0",
+				"dot-prop": "^6.0.1",
+				"env-paths": "^2.2.1",
+				"jsonwebtoken": "^8.5.1",
+				"missing-native-js-functions": "^1.2.2",
+				"mongodb": "^3.6.9",
+				"mongoose": "^5.13.7",
+				"mongoose-autopopulate": "^0.12.3",
+				"typescript": "^4.1.3"
+			}
+		},
 		"@istanbuljs/load-nyc-config": {
 			"version": "1.1.0",
 			"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
diff --git a/api/package.json b/api/package.json
index 8a0bbdd1..c9dd6b1f 100644
--- a/api/package.json
+++ b/api/package.json
@@ -5,6 +5,8 @@
 	"main": "dist/Server.js",
 	"types": "dist/Server.d.ts",
 	"scripts": {
+		"link": "npm run build && npm link",
+		"postinstall": "npm run --prefix ../util/ link && npm link @fosscord/util && npm run link",
 		"test": "jest",
 		"test:watch": "jest --watch",
 		"start": "npm run build && node dist/start",
@@ -33,7 +35,7 @@
 	},
 	"homepage": "https://github.com/fosscord/fosscord-api#readme",
 	"dependencies": {
-		"@fosscord/server-util": "file:../util",
+		"@fosscord/util": "file:../util",
 		"@types/jest": "^26.0.22",
 		"@types/json-schema": "^7.0.7",
 		"ajv": "^8.4.0",
diff --git a/api/src/Server.ts b/api/src/Server.ts
index 7299425a..a60c5e4d 100644
--- a/api/src/Server.ts
+++ b/api/src/Server.ts
@@ -3,7 +3,7 @@ import fs from "fs";
 import { Connection } from "mongoose";
 import { Server, ServerOptions } from "lambert-server";
 import { Authentication, CORS } from "./middlewares/";
-import { Config, db, RabbitMQ } from "@fosscord/server-util";
+import { Config, db, initEvent, RabbitMQ } from "@fosscord/util";
 import i18next from "i18next";
 import i18nextMiddleware, { I18next } from "i18next-http-middleware";
 import i18nextBackend from "i18next-node-fs-backend";
@@ -56,9 +56,8 @@ export class FosscordServer extends Server {
 		// @ts-ignore
 		await (db as Promise<Connection>);
 		await this.setupSchema();
-		console.log("[Database] connected");
 		await Config.init();
-		await RabbitMQ.init();
+		await initEvent();
 
 		this.app.use(CORS);
 		this.app.use(Authentication);
@@ -93,11 +92,12 @@ export class FosscordServer extends Server {
 		app.use("/api/v9", api);
 		app.use("/api", api); // allow unversioned requests
 
-		api.get("*", (req: Request, res: Response) => {
+		api.get("*", (req: Request, res: Response, next) => {
 			res.status(404).json({
 				message: "404: Not Found",
 				code: 0
 			});
+			next();
 		});
 
 		this.app = app;
diff --git a/api/src/index.ts b/api/src/index.ts
index 554c296f..6037e31f 100644
--- a/api/src/index.ts
+++ b/api/src/index.ts
@@ -7,9 +7,7 @@ export * from "./schema/Invite";
 export * from "./schema/Message";
 export * from "./util/Config";
 export * from "./util/Constants";
-export * from "./util/Event";
 export * from "./util/instanceOf";
-export * from "./util/Event";
 export * from "./util/instanceOf";
 export * from "./util/Member";
 export * from "./util/RandomInviteID";
diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts
index 01b7ef57..00cd9ea7 100644
--- a/api/src/middlewares/Authentication.ts
+++ b/api/src/middlewares/Authentication.ts
@@ -1,15 +1,15 @@
 import { NextFunction, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
-import { checkToken, Config } from "@fosscord/server-util";
+import { checkToken, Config } from "@fosscord/util";
 
 export const NO_AUTHORIZATION_ROUTES = [
-	/^\/api(\/v\d+)?\/auth\/login/,
-	/^\/api(\/v\d+)?\/auth\/register/,
-	/^\/api(\/v\d+)?\/webhooks\//,
-	/^\/api(\/v\d+)?\/ping/,
-	/^\/api(\/v\d+)?\/gateway/,
-	/^\/api(\/v\d+)?\/experiments/,
-	/^\/api(\/v\d+)?\/guilds\/\d+\/widget\.(json|png)/
+	"/auth/login",
+	"/auth/register",
+	"/webhooks/",
+	"/ping",
+	"/gateway",
+	"/experiments"
+	// /^\/api(\/v\d+)?\/guilds\/\d+\/widget\.(json|png)/
 ];
 
 export const API_PREFIX = /^\/api(\/v\d+)?/;
@@ -24,13 +24,14 @@ declare global {
 		}
 	}
 }
+// TODO wenn client offen ist, wird http://localhost:8080/api/v9/users/@me/guild-events blockiert?
 
 export async function Authentication(req: Request, res: Response, next: NextFunction) {
 	if (req.method === "OPTIONS") return res.sendStatus(204);
 	if (!req.url.startsWith("/api")) return next();
 	const apiPath = req.url.replace(API_PREFIX, "");
-	if (apiPath.startsWith("/invites") && req.method === "GET") return next();
-	if (NO_AUTHORIZATION_ROUTES.some((x) => x.test(req.url))) return next();
+	if (apiPath.startsWith("/invites") && req.method === "GET") return next(); // @ts-ignore
+	if (NO_AUTHORIZATION_ROUTES.some((x) => apiPath.startsWith(x) || x.test?.(req.url))) return next();
 	if (!req.headers.authorization) return next(new HTTPError("Missing Authorization Header", 401));
 
 	try {
diff --git a/api/src/middlewares/ErrorHandler.ts b/api/src/middlewares/ErrorHandler.ts
index 2e6b1d8b..04d56026 100644
--- a/api/src/middlewares/ErrorHandler.ts
+++ b/api/src/middlewares/ErrorHandler.ts
@@ -25,8 +25,6 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne
 		if (httpcode > 511) httpcode = 400;
 
 		res.status(httpcode).json({ code: code, message, errors });
-
-		return;
 	} catch (error) {
 		console.error(error);
 		return res.status(500).json({ code: 500, message: "Internal Server Error" });
diff --git a/api/src/middlewares/RateLimit.ts b/api/src/middlewares/RateLimit.ts
index c8fdeba2..a1bb0c44 100644
--- a/api/src/middlewares/RateLimit.ts
+++ b/api/src/middlewares/RateLimit.ts
@@ -1,16 +1,17 @@
-import { db, MongooseCache, Bucket, Config } from "@fosscord/server-util";
+// @ts-nocheck
+import { db, Bucket, Config } from "@fosscord/util";
 import { NextFunction, Request, Response, Router } from "express";
 import { getIpAdress } from "../util/ipAddress";
 import { API_PREFIX_TRAILING_SLASH } from "./Authentication";
 
-const Cache = new MongooseCache(
-	db.collection("ratelimits"),
-	[
-		// TODO: uncomment $match and fix error: not receiving change events
-		// { $match: { blocked: true } }
-	],
-	{ onlyEvents: false, array: true }
-);
+// const Cache = new MongooseCache(
+// 	db.collection("ratelimits"),
+// 	[
+// 		// TODO: uncomment $match and fix error: not receiving change events
+// 		// { $match: { blocked: true } }
+// 	],
+// 	{ onlyEvents: false, array: true }
+// );
 
 // Docs: https://discord.com/developers/docs/topics/rate-limits
 
@@ -31,6 +32,7 @@ TODO: use config values
 
 */
 
+// TODO: FIX with new event handling
 export default function RateLimit(opts: {
 	bucket?: string;
 	window: number;
@@ -44,6 +46,7 @@ export default function RateLimit(opts: {
 	success?: boolean;
 	onlyIp?: boolean;
 }): any {
+	return (req, res, next) => next();
 	Cache.init(); // will only initalize it once
 
 	return async (req: Request, res: Response, next: NextFunction): Promise<any> => {
diff --git a/api/src/routes/auth/login.ts b/api/src/routes/auth/login.ts
index c3661608..f55d5351 100644
--- a/api/src/routes/auth/login.ts
+++ b/api/src/routes/auth/login.ts
@@ -2,7 +2,7 @@ import { Request, Response, Router } from "express";
 import { check, FieldErrors, Length } from "../../util/instanceOf";
 import bcrypt from "bcrypt";
 import jwt from "jsonwebtoken";
-import { Config, UserModel } from "@fosscord/server-util";
+import { Config, UserModel } from "@fosscord/util";
 import { adjustEmail } from "./register";
 import RateLimit from "../../middlewares/RateLimit";
 
diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts
index 66a1fc8d..fecde874 100644
--- a/api/src/routes/auth/register.ts
+++ b/api/src/routes/auth/register.ts
@@ -1,5 +1,5 @@
 import { Request, Response, Router } from "express";
-import { trimSpecial, User, Snowflake, UserModel, Config } from "@fosscord/server-util";
+import { trimSpecial, User, Snowflake, UserModel, Config } from "@fosscord/util";
 import bcrypt from "bcrypt";
 import { check, Email, EMAIL_REGEX, FieldErrors, Length } from "../../util/instanceOf";
 import "missing-native-js-functions";
diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts
index 81e5054e..3bfa80be 100644
--- a/api/src/routes/channels/#channel_id/index.ts
+++ b/api/src/routes/channels/#channel_id/index.ts
@@ -1,8 +1,7 @@
-import { ChannelDeleteEvent, ChannelModel, ChannelUpdateEvent, getPermission, GuildUpdateEvent, toObject } from "@fosscord/server-util";
+import { ChannelDeleteEvent, ChannelModel, ChannelUpdateEvent, emitEvent, getPermission, GuildUpdateEvent, toObject } from "@fosscord/util";
 import { Router, Response, Request } from "express";
 import { HTTPError } from "lambert-server";
 import { ChannelModifySchema } from "../../../schema/Channel";
-import { emitEvent } from "../../../util/Event";
 import { check } from "../../../util/instanceOf";
 const router: Router = Router();
 // TODO: delete channel
diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts
index c9db4dd2..438f8c51 100644
--- a/api/src/routes/channels/#channel_id/invites.ts
+++ b/api/src/routes/channels/#channel_id/invites.ts
@@ -3,11 +3,10 @@ import { HTTPError } from "lambert-server";
 
 import { check } from "../../../util/instanceOf";
 import { random } from "../../../util/RandomInviteID";
-import { emitEvent } from "../../../util/Event";
 
 import { InviteCreateSchema } from "../../../schema/Invite";
 
-import { getPermission, ChannelModel, InviteModel, InviteCreateEvent, toObject } from "@fosscord/server-util";
+import { getPermission, ChannelModel, InviteModel, InviteCreateEvent, toObject, emitEvent } from "@fosscord/util";
 
 const router: Router = Router();
 
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts b/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts
index f4d9e696..bbc779dd 100644
--- a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts
+++ b/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts
@@ -1,6 +1,6 @@
-import { getPermission, MessageAckEvent, ReadStateModel } from "@fosscord/server-util";
+import { emitEvent, getPermission, MessageAckEvent, ReadStateModel } from "@fosscord/util";
 import { Request, Response, Router } from "express";
-import { emitEvent } from "../../../../../util/Event";
+
 import { check } from "../../../../../util/instanceOf";
 
 const router = Router();
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts
index a7c23d2f..3c58d034 100644
--- a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts
+++ b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts
@@ -1,8 +1,8 @@
-import { ChannelModel, getPermission, MessageDeleteEvent, MessageModel, MessageUpdateEvent, toObject } from "@fosscord/server-util";
+import { ChannelModel, emitEvent, getPermission, MessageDeleteEvent, MessageModel, MessageUpdateEvent, toObject } from "@fosscord/util";
 import { Router, Response, Request } from "express";
 import { HTTPError } from "lambert-server";
 import { MessageCreateSchema } from "../../../../../schema/Message";
-import { emitEvent } from "../../../../../util/Event";
+
 import { check } from "../../../../../util/instanceOf";
 import { handleMessage, postHandleMessage } from "../../../../../util/Message";
 
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
index 168a870f..34d2ce3a 100644
--- a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
+++ b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -1,5 +1,6 @@
 import {
 	ChannelModel,
+	emitEvent,
 	EmojiModel,
 	getPermission,
 	MemberModel,
@@ -12,10 +13,9 @@ import {
 	PublicUserProjection,
 	toObject,
 	UserModel
-} from "@fosscord/server-util";
+} from "@fosscord/util";
 import { Router, Response, Request } from "express";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../../../util/Event";
 
 const router = Router();
 // TODO: check if emoji is really an unicode emoji or a prperly encoded external emoji
diff --git a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts b/api/src/routes/channels/#channel_id/messages/bulk-delete.ts
index e53cd597..8132462f 100644
--- a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts
+++ b/api/src/routes/channels/#channel_id/messages/bulk-delete.ts
@@ -1,7 +1,7 @@
 import { Router, Response, Request } from "express";
-import { ChannelModel, Config, getPermission, MessageDeleteBulkEvent, MessageModel } from "@fosscord/server-util";
+import { ChannelModel, Config, emitEvent, getPermission, MessageDeleteBulkEvent, MessageModel } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../../util/Event";
+
 import { check } from "../../../../util/instanceOf";
 
 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 fea4d6a4..6ae6491f 100644
--- a/api/src/routes/channels/#channel_id/messages/index.ts
+++ b/api/src/routes/channels/#channel_id/messages/index.ts
@@ -1,5 +1,5 @@
 import { Router, Response, Request } from "express";
-import { Attachment, ChannelModel, ChannelType, getPermission, MessageDocument, MessageModel, toObject } from "@fosscord/server-util";
+import { Attachment, ChannelModel, ChannelType, getPermission, MessageDocument, MessageModel, toObject } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { MessageCreateSchema } from "../../../../schema/Message";
 import { check, instanceOf, Length } from "../../../../util/instanceOf";
diff --git a/api/src/routes/channels/#channel_id/permissions.ts b/api/src/routes/channels/#channel_id/permissions.ts
index 12364293..4cbc7522 100644
--- a/api/src/routes/channels/#channel_id/permissions.ts
+++ b/api/src/routes/channels/#channel_id/permissions.ts
@@ -1,7 +1,15 @@
-import { ChannelModel, ChannelPermissionOverwrite, ChannelUpdateEvent, getPermission, MemberModel, RoleModel } from "@fosscord/server-util";
+import {
+	ChannelModel,
+	ChannelPermissionOverwrite,
+	ChannelUpdateEvent,
+	emitEvent,
+	getPermission,
+	MemberModel,
+	RoleModel
+} from "@fosscord/util";
 import { Router, Response, Request } from "express";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
+
 import { check } from "../../../util/instanceOf";
 const router: Router = Router();
 
diff --git a/api/src/routes/channels/#channel_id/pins.ts b/api/src/routes/channels/#channel_id/pins.ts
index 65d6b975..18a5861b 100644
--- a/api/src/routes/channels/#channel_id/pins.ts
+++ b/api/src/routes/channels/#channel_id/pins.ts
@@ -2,14 +2,14 @@ import {
 	ChannelModel,
 	ChannelPinsUpdateEvent,
 	Config,
+	emitEvent,
 	getPermission,
 	MessageModel,
 	MessageUpdateEvent,
 	toObject
-} from "@fosscord/server-util";
+} from "@fosscord/util";
 import { Router, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
 
 const router: Router = Router();
 
diff --git a/api/src/routes/channels/#channel_id/typing.ts b/api/src/routes/channels/#channel_id/typing.ts
index de549883..21d453d8 100644
--- a/api/src/routes/channels/#channel_id/typing.ts
+++ b/api/src/routes/channels/#channel_id/typing.ts
@@ -1,8 +1,7 @@
-import { ChannelModel, MemberModel, toObject, TypingStartEvent } from "@fosscord/server-util";
+import { ChannelModel, emitEvent, MemberModel, toObject, TypingStartEvent } from "@fosscord/util";
 import { Router, Request, Response } from "express";
 
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
 
 const router: Router = Router();
 
diff --git a/api/src/routes/channels/#channel_id/webhooks.ts b/api/src/routes/channels/#channel_id/webhooks.ts
index 6c1aea2a..7852f8f3 100644
--- a/api/src/routes/channels/#channel_id/webhooks.ts
+++ b/api/src/routes/channels/#channel_id/webhooks.ts
@@ -1,6 +1,6 @@
 import { Router, Response, Request } from "express";
 import { check, Length } from "../../../util/instanceOf";
-import { ChannelModel, getPermission, trimSpecial } from "@fosscord/server-util";
+import { ChannelModel, getPermission, trimSpecial } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { isTextChannel } from "./messages/index";
 
diff --git a/api/src/routes/gateway.ts b/api/src/routes/gateway.ts
index f2bc5b34..3120718e 100644
--- a/api/src/routes/gateway.ts
+++ b/api/src/routes/gateway.ts
@@ -1,4 +1,4 @@
-import { Config } from "@fosscord/server-util";
+import { Config } from "@fosscord/util";
 import { Router, Response, Request } from "express";
 
 const router = Router();
diff --git a/api/src/routes/guilds/#guild_id/bans.ts b/api/src/routes/guilds/#guild_id/bans.ts
index d9752f61..bb3eac03 100644
--- a/api/src/routes/guilds/#guild_id/bans.ts
+++ b/api/src/routes/guilds/#guild_id/bans.ts
@@ -1,9 +1,9 @@
 import { Request, Response, Router } from "express";
-import { BanModel, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, GuildModel, toObject } from "@fosscord/server-util";
+import { BanModel, emitEvent, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, GuildModel, toObject } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { getIpAdress } from "../../../util/ipAddress";
 import { BanCreateSchema } from "../../../schema/Ban";
-import { emitEvent } from "../../../util/Event";
+
 import { check } from "../../../util/instanceOf";
 import { removeMember } from "../../../util/Member";
 import { getPublicUser } from "../../../util/User";
diff --git a/api/src/routes/guilds/#guild_id/channels.ts b/api/src/routes/guilds/#guild_id/channels.ts
index 52361f5e..8d97cf96 100644
--- a/api/src/routes/guilds/#guild_id/channels.ts
+++ b/api/src/routes/guilds/#guild_id/channels.ts
@@ -8,11 +8,12 @@ import {
 	toObject,
 	ChannelUpdateEvent,
 	AnyChannel,
-	getPermission
-} from "@fosscord/server-util";
+	getPermission,
+	emitEvent
+} from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { ChannelModifySchema } from "../../../schema/Channel";
-import { emitEvent } from "../../../util/Event";
+
 import { check } from "../../../util/instanceOf";
 import { createChannel } from "../../../util/Channel";
 const router = Router();
@@ -64,7 +65,7 @@ router.patch(
 
 		const channel = await ChannelModel.findOneAndUpdate({ id: req.body, guild_id }, opts).exec();
 
-		await emitEvent({ event: "CHANNEL_UPDATE", data: channel, channel_id: body.id, guild_id } as ChannelUpdateEvent);
+		await emitEvent({ event: "CHANNEL_UPDATE", data: toObject(channel), channel_id: body.id, guild_id } as ChannelUpdateEvent);
 
 		res.json(toObject(channel));
 	}
diff --git a/api/src/routes/guilds/#guild_id/delete.ts b/api/src/routes/guilds/#guild_id/delete.ts
index 6cca289e..ba1c2fde 100644
--- a/api/src/routes/guilds/#guild_id/delete.ts
+++ b/api/src/routes/guilds/#guild_id/delete.ts
@@ -1,5 +1,6 @@
 import {
 	ChannelModel,
+	emitEvent,
 	EmojiModel,
 	GuildDeleteEvent,
 	GuildModel,
@@ -8,10 +9,9 @@ import {
 	MessageModel,
 	RoleModel,
 	UserModel
-} from "@fosscord/server-util";
+} from "@fosscord/util";
 import { Router, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
 
 const router = Router();
 
diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts
index dc4ddb39..1afa603f 100644
--- a/api/src/routes/guilds/#guild_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/index.ts
@@ -1,6 +1,7 @@
 import { Request, Response, Router } from "express";
 import {
 	ChannelModel,
+	emitEvent,
 	EmojiModel,
 	getPermission,
 	GuildDeleteEvent,
@@ -12,10 +13,10 @@ import {
 	RoleModel,
 	toObject,
 	UserModel
-} from "@fosscord/server-util";
+} from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { GuildUpdateSchema } from "../../../schema/Guild";
-import { emitEvent } from "../../../util/Event";
+
 import { check } from "../../../util/instanceOf";
 import { handleFile } from "../../../util/cdn";
 import "missing-native-js-functions";
diff --git a/api/src/routes/guilds/#guild_id/invites.ts b/api/src/routes/guilds/#guild_id/invites.ts
index 1894ec96..08048d61 100644
--- a/api/src/routes/guilds/#guild_id/invites.ts
+++ b/api/src/routes/guilds/#guild_id/invites.ts
@@ -1,4 +1,4 @@
-import { getPermission, InviteModel, toObject } from "@fosscord/server-util";
+import { getPermission, InviteModel, toObject } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 
 const router = Router();
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
index 9a1676e6..eac6684a 100644
--- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -8,13 +8,13 @@ import {
 	getPermission,
 	PermissionResolvable,
 	RoleModel,
-	GuildMemberUpdateEvent
-} from "@fosscord/server-util";
+	GuildMemberUpdateEvent,
+	emitEvent
+} from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { addMember, isMember, removeMember } from "../../../../../util/Member";
 import { check } from "../../../../../util/instanceOf";
 import { MemberChangeSchema } from "../../../../../schema/Member";
-import { emitEvent } from "../../../../../util/Event";
 
 const router = Router();
 
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts b/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts
index 9078409d..5784b5d5 100644
--- a/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts
+++ b/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts
@@ -1,4 +1,4 @@
-import { getPermission, PermissionResolvable } from "@fosscord/server-util";
+import { getPermission, PermissionResolvable } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 import { check } from "lambert-server";
 import { MemberNickChangeSchema } from "../../../../../schema/Member";
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
index b7a43c74..fad0695e 100644
--- a/api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
@@ -1,4 +1,4 @@
-import { getPermission } from "@fosscord/server-util";
+import { getPermission } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 import { addRole, removeRole } from "../../../../../../../util/Member";
 
diff --git a/api/src/routes/guilds/#guild_id/members/index.ts b/api/src/routes/guilds/#guild_id/members/index.ts
index a157d8f5..70303436 100644
--- a/api/src/routes/guilds/#guild_id/members/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/index.ts
@@ -1,5 +1,5 @@
 import { Request, Response, Router } from "express";
-import { GuildModel, MemberModel, toObject } from "@fosscord/server-util";
+import { GuildModel, MemberModel, toObject } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { instanceOf, Length } from "../../../../util/instanceOf";
 import { PublicMemberProjection, isMember } from "../../../../util/Member";
diff --git a/api/src/routes/guilds/#guild_id/regions.ts b/api/src/routes/guilds/#guild_id/regions.ts
index 3a46d766..5ec649ee 100644
--- a/api/src/routes/guilds/#guild_id/regions.ts
+++ b/api/src/routes/guilds/#guild_id/regions.ts
@@ -1,4 +1,4 @@
-import { Config } from "@fosscord/server-util";
+import { Config } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 
 const router = Router();
@@ -7,4 +7,4 @@ router.get("/", async (req: Request, res: Response) => {
 	return res.json(Config.get().regions.available);
 });
 
-export default router;
\ No newline at end of file
+export default router;
diff --git a/api/src/routes/guilds/#guild_id/roles.ts b/api/src/routes/guilds/#guild_id/roles.ts
index 77206a0f..a4bc44e0 100644
--- a/api/src/routes/guilds/#guild_id/roles.ts
+++ b/api/src/routes/guilds/#guild_id/roles.ts
@@ -9,10 +9,11 @@ import {
 	MemberModel,
 	GuildRoleCreateEvent,
 	GuildRoleUpdateEvent,
-	GuildRoleDeleteEvent
-} from "@fosscord/server-util";
+	GuildRoleDeleteEvent,
+	emitEvent
+} from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
+
 import { check } from "../../../util/instanceOf";
 import { RoleModifySchema } from "../../../schema/Roles";
 import { getPublicUser } from "../../../util/User";
diff --git a/api/src/routes/guilds/#guild_id/templates.ts b/api/src/routes/guilds/#guild_id/templates.ts
index 8306ac37..fdca1c40 100644
--- a/api/src/routes/guilds/#guild_id/templates.ts
+++ b/api/src/routes/guilds/#guild_id/templates.ts
@@ -1,5 +1,5 @@
 import { Request, Response, Router } from "express";
-import { TemplateModel, GuildModel, getPermission, toObject, UserModel, Snowflake } from "@fosscord/server-util";
+import { TemplateModel, GuildModel, getPermission, toObject, UserModel, Snowflake } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { TemplateCreateSchema, TemplateModifySchema } from "../../../schema/Template";
 import { check } from "../../../util/instanceOf";
diff --git a/api/src/routes/guilds/#guild_id/vanity-url.ts b/api/src/routes/guilds/#guild_id/vanity-url.ts
index 323b2647..86adfeb0 100644
--- a/api/src/routes/guilds/#guild_id/vanity-url.ts
+++ b/api/src/routes/guilds/#guild_id/vanity-url.ts
@@ -1,4 +1,4 @@
-import { getPermission, GuildModel, InviteModel, trimSpecial } from "@fosscord/server-util";
+import { getPermission, GuildModel, InviteModel, trimSpecial } from "@fosscord/util";
 import { Router, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
 import { check, Length } from "../../../util/instanceOf";
diff --git a/api/src/routes/guilds/#guild_id/welcome_screen.ts b/api/src/routes/guilds/#guild_id/welcome_screen.ts
index 656a0ee0..c717042e 100644
--- a/api/src/routes/guilds/#guild_id/welcome_screen.ts
+++ b/api/src/routes/guilds/#guild_id/welcome_screen.ts
@@ -1,7 +1,7 @@
 import { Request, Response, Router } from "express";
-import { GuildModel, getPermission, toObject, Snowflake } from "@fosscord/server-util";
+import { GuildModel, getPermission, toObject, Snowflake } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
+
 import { check } from "../../../util/instanceOf";
 import { isMember } from "../../../util/Member";
 import { GuildAddChannelToWelcomeScreenSchema } from "../../../schema/Guild";
diff --git a/api/src/routes/guilds/#guild_id/widget.json.ts b/api/src/routes/guilds/#guild_id/widget.json.ts
index 6f777ab4..8719bd85 100644
--- a/api/src/routes/guilds/#guild_id/widget.json.ts
+++ b/api/src/routes/guilds/#guild_id/widget.json.ts
@@ -1,5 +1,5 @@
 import { Request, Response, Router } from "express";
-import { Config, Permissions, GuildModel, InviteModel, ChannelModel, MemberModel } from "@fosscord/server-util";
+import { Config, Permissions, GuildModel, InviteModel, ChannelModel, MemberModel } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { random } from "../../../util/RandomInviteID";
 
diff --git a/api/src/routes/guilds/#guild_id/widget.png.ts b/api/src/routes/guilds/#guild_id/widget.png.ts
index a0a8c938..80dc9f2b 100644
--- a/api/src/routes/guilds/#guild_id/widget.png.ts
+++ b/api/src/routes/guilds/#guild_id/widget.png.ts
@@ -1,5 +1,5 @@
 import { Request, Response, Router } from "express";
-import { GuildModel } from "@fosscord/server-util";
+import { GuildModel } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import fs from "fs";
 import path from "path";
diff --git a/api/src/routes/guilds/#guild_id/widget.ts b/api/src/routes/guilds/#guild_id/widget.ts
index 0e6df186..85eed5e9 100644
--- a/api/src/routes/guilds/#guild_id/widget.ts
+++ b/api/src/routes/guilds/#guild_id/widget.ts
@@ -1,5 +1,5 @@
 import { Request, Response, Router } from "express";
-import { getPermission, GuildModel } from "@fosscord/server-util";
+import { getPermission, GuildModel } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { check } from "../../../util/instanceOf";
 import { WidgetModifySchema } from "../../../schema/Widget";
diff --git a/api/src/routes/guilds/index.ts b/api/src/routes/guilds/index.ts
index 25b55896..c97a8205 100644
--- a/api/src/routes/guilds/index.ts
+++ b/api/src/routes/guilds/index.ts
@@ -1,5 +1,5 @@
 import { Router, Request, Response } from "express";
-import { RoleModel, GuildModel, Snowflake, Guild, RoleDocument, Config } from "@fosscord/server-util";
+import { RoleModel, GuildModel, Snowflake, Guild, RoleDocument, Config } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { check } from "./../../util/instanceOf";
 import { GuildCreateSchema } from "../../schema/Guild";
diff --git a/api/src/routes/guilds/templates/index.ts b/api/src/routes/guilds/templates/index.ts
index 0f332de0..7fed3c5d 100644
--- a/api/src/routes/guilds/templates/index.ts
+++ b/api/src/routes/guilds/templates/index.ts
@@ -1,6 +1,6 @@
 import { Request, Response, Router } from "express";
 const router: Router = Router();
-import { TemplateModel, GuildModel, toObject, UserModel, RoleModel, Snowflake, Guild, Config } from "@fosscord/server-util";
+import { TemplateModel, GuildModel, toObject, UserModel, RoleModel, Snowflake, Guild, Config } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { GuildTemplateCreateSchema } from "../../../schema/Guild";
 import { getPublicUser } from "../../../util/User";
diff --git a/api/src/routes/invites/index.ts b/api/src/routes/invites/index.ts
index 8c04713c..992694df 100644
--- a/api/src/routes/invites/index.ts
+++ b/api/src/routes/invites/index.ts
@@ -1,5 +1,5 @@
 import { Router, Request, Response } from "express";
-import { getPermission, InviteModel, toObject } from "@fosscord/server-util";
+import { getPermission, InviteModel, toObject } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { addMember } from "../../util/Member";
 const router: Router = Router();
diff --git a/api/src/routes/users/@me/channels.ts b/api/src/routes/users/@me/channels.ts
index a425a25f..db9f8832 100644
--- a/api/src/routes/users/@me/channels.ts
+++ b/api/src/routes/users/@me/channels.ts
@@ -8,10 +8,11 @@ import {
 	trimSpecial,
 	Channel,
 	DMChannel,
-	UserModel
-} from "@fosscord/server-util";
+	UserModel,
+	emitEvent
+} from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
+
 import { DmChannelCreateSchema } from "../../../schema/Channel";
 import { check } from "../../../util/instanceOf";
 
diff --git a/api/src/routes/users/@me/delete.ts b/api/src/routes/users/@me/delete.ts
index edda8e2d..f863237d 100644
--- a/api/src/routes/users/@me/delete.ts
+++ b/api/src/routes/users/@me/delete.ts
@@ -1,5 +1,5 @@
 import { Router, Request, Response } from "express";
-import { GuildModel, MemberModel, UserModel } from "@fosscord/server-util";
+import { GuildModel, MemberModel, UserModel } from "@fosscord/util";
 import bcrypt from "bcrypt";
 const router = Router();
 
diff --git a/api/src/routes/users/@me/disable.ts b/api/src/routes/users/@me/disable.ts
index 0e5b734e..2d3a9850 100644
--- a/api/src/routes/users/@me/disable.ts
+++ b/api/src/routes/users/@me/disable.ts
@@ -1,4 +1,4 @@
-import { UserModel } from "@fosscord/server-util";
+import { UserModel } from "@fosscord/util";
 import { Router, Response, Request } from "express";
 import bcrypt from "bcrypt";
 
diff --git a/api/src/routes/users/@me/guilds.ts b/api/src/routes/users/@me/guilds.ts
index 6528552b..a9b53b75 100644
--- a/api/src/routes/users/@me/guilds.ts
+++ b/api/src/routes/users/@me/guilds.ts
@@ -1,7 +1,7 @@
 import { Router, Request, Response } from "express";
-import { GuildModel, MemberModel, UserModel, GuildDeleteEvent, GuildMemberRemoveEvent, toObject } from "@fosscord/server-util";
+import { GuildModel, MemberModel, UserModel, GuildDeleteEvent, GuildMemberRemoveEvent, toObject, emitEvent } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
+
 import { getPublicUser } from "../../../util/User";
 
 const router: Router = Router();
@@ -32,10 +32,10 @@ router.delete("/:id", async (req: Request, res: Response) => {
 		emitEvent({
 			event: "GUILD_DELETE",
 			data: {
-				id: guild_id,
+				id: guild_id
 			},
-			user_id: req.user_id,
-		} as GuildDeleteEvent),
+			user_id: req.user_id
+		} as GuildDeleteEvent)
 	]);
 
 	const user = await getPublicUser(req.user_id);
@@ -44,9 +44,9 @@ router.delete("/:id", async (req: Request, res: Response) => {
 		event: "GUILD_MEMBER_REMOVE",
 		data: {
 			guild_id: guild_id,
-			user: user,
+			user: user
 		},
-		guild_id: guild_id,
+		guild_id: guild_id
 	} as GuildMemberRemoveEvent);
 
 	return res.sendStatus(204);
diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts
index 7bd4a486..c073e78a 100644
--- a/api/src/routes/users/@me/index.ts
+++ b/api/src/routes/users/@me/index.ts
@@ -1,5 +1,5 @@
 import { Router, Request, Response } from "express";
-import { UserModel, toObject, PublicUserProjection } from "@fosscord/server-util";
+import { UserModel, toObject, PublicUserProjection } from "@fosscord/util";
 import { getPublicUser } from "../../../util/User";
 import { UserModifySchema } from "../../../schema/User";
 import { check } from "../../../util/instanceOf";
diff --git a/api/src/routes/users/@me/relationships.ts b/api/src/routes/users/@me/relationships.ts
index a8f03143..642ee5f9 100644
--- a/api/src/routes/users/@me/relationships.ts
+++ b/api/src/routes/users/@me/relationships.ts
@@ -5,11 +5,12 @@ import {
 	toObject,
 	RelationshipType,
 	RelationshipRemoveEvent,
-	UserDocument
-} from "@fosscord/server-util";
+	UserDocument,
+	emitEvent
+} from "@fosscord/util";
 import { Router, Response, Request } from "express";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "../../../util/Event";
+
 import { check, Length } from "../../../util/instanceOf";
 
 const router = Router();
diff --git a/api/src/schema/Channel.ts b/api/src/schema/Channel.ts
index 48c3a1d2..18a8f835 100644
--- a/api/src/schema/Channel.ts
+++ b/api/src/schema/Channel.ts
@@ -1,4 +1,4 @@
-import { ChannelType } from "@fosscord/server-util";
+import { ChannelType } from "@fosscord/util";
 import { Length } from "../util/instanceOf";
 
 export const ChannelModifySchema = {
diff --git a/api/src/schema/Guild.ts b/api/src/schema/Guild.ts
index 0443e64c..ce40b49f 100644
--- a/api/src/schema/Guild.ts
+++ b/api/src/schema/Guild.ts
@@ -1,4 +1,4 @@
-import { ChannelSchema, GuildChannel } from "@fosscord/server-util";
+import { ChannelSchema, GuildChannel } from "@fosscord/util";
 import { Length } from "../util/instanceOf";
 
 export const GuildCreateSchema = {
diff --git a/api/src/schema/Message.ts b/api/src/schema/Message.ts
index 8423d706..2dd54f0c 100644
--- a/api/src/schema/Message.ts
+++ b/api/src/schema/Message.ts
@@ -1,4 +1,4 @@
-import { Embed, EmbedImage } from "@fosscord/server-util";
+import { Embed, EmbedImage } from "@fosscord/util";
 import { Length } from "../util/instanceOf";
 
 export const MessageCreateSchema = {
diff --git a/api/src/test/test.ts b/api/src/test/test.ts
index 478edcc4..c37c762b 100644
--- a/api/src/test/test.ts
+++ b/api/src/test/test.ts
@@ -1,3 +1,3 @@
-import { Snowflake } from "@fosscord/server-util";
+import { Snowflake } from "@fosscord/util";
 
 console.log(Snowflake.deconstruct("0"));
diff --git a/api/src/util/Channel.ts b/api/src/util/Channel.ts
index 4d322812..ef04d521 100644
--- a/api/src/util/Channel.ts
+++ b/api/src/util/Channel.ts
@@ -2,18 +2,18 @@ import {
 	ChannelCreateEvent,
 	ChannelModel,
 	ChannelType,
+	emitEvent,
 	getPermission,
 	GuildModel,
 	Snowflake,
 	TextChannel,
+	toObject,
 	VoiceChannel
-} from "@fosscord/server-util";
+} from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "./Event";
 
 // TODO: DM channel
 export async function createChannel(channel: Partial<TextChannel | VoiceChannel>, user_id: string = "0") {
-
 	// Always check if user has permission first
 	const permissions = await getPermission(user_id, channel.guild_id);
 	permissions.hasThrow("MANAGE_CHANNELS");
@@ -50,7 +50,7 @@ export async function createChannel(channel: Partial<TextChannel | VoiceChannel>
 		recipient_ids: null
 	}).save();
 
-	await emitEvent({ event: "CHANNEL_CREATE", data: channel, guild_id: channel.guild_id } as ChannelCreateEvent);
+	await emitEvent({ event: "CHANNEL_CREATE", data: toObject(channel), guild_id: channel.guild_id } as ChannelCreateEvent);
 
 	return channel;
 }
diff --git a/api/src/util/Config.ts b/api/src/util/Config.ts
index e2e0d312..c86afbe7 100644
--- a/api/src/util/Config.ts
+++ b/api/src/util/Config.ts
@@ -1,7 +1,7 @@
 // @ts-nocheck
 import Ajv, { JSONSchemaType } from "ajv";
-import { getConfigPathForFile } from "@fosscord/server-util/dist/util/Config";
-import { Config } from "@fosscord/server-util";
+import { getConfigPathForFile } from "@fosscord/util/dist/util/Config";
+import { Config } from "@fosscord/util";
 
 export interface RateLimitOptions {
 	count: number;
diff --git a/api/src/util/Event.ts b/api/src/util/Event.ts
deleted file mode 100644
index 4dd56417..00000000
--- a/api/src/util/Event.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Config, Event, EventModel, RabbitMQ } from "@fosscord/server-util";
-
-export async function emitEvent(payload: Omit<Event, "created_at">) {
-	if (RabbitMQ.connection) {
-		const id = (payload.channel_id || payload.user_id || payload.guild_id) as string;
-		if (!id) console.error("event doesn't contain any id", payload);
-		const data = typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.data; // use rabbitmq for event transmission
-		await RabbitMQ.channel?.assertExchange(id, "fanout", { durable: false });
-
-		// assertQueue isn't needed, because a queue will automatically created if it doesn't exist
-		const successful = RabbitMQ.channel?.publish(id, "", Buffer.from(`${data}`), { type: payload.event });
-		if (!successful) throw new Error("failed to send event");
-	} else {
-		// use mongodb for event transmission
-		// TODO: use event emitter for local server bundle
-		const obj = {
-			created_at: new Date(), // in seconds
-			...payload
-		};
-		// TODO: bigint isn't working
-
-		return await new EventModel(obj).save();
-	}
-}
-
-export async function emitAuditLog(payload: any) {}
diff --git a/api/src/util/Member.ts b/api/src/util/Member.ts
index 7b06720b..ee3f64ad 100644
--- a/api/src/util/Member.ts
+++ b/api/src/util/Member.ts
@@ -11,11 +11,12 @@ import {
 	toObject,
 	UserModel,
 	GuildDocument,
-	Config
-} from "@fosscord/server-util";
+	Config,
+	emitEvent
+} from "@fosscord/util";
 
 import { HTTPError } from "lambert-server";
-import { emitEvent } from "./Event";
+
 import { getPublicUser } from "./User";
 
 export const PublicMemberProjection = {
diff --git a/api/src/util/Message.ts b/api/src/util/Message.ts
index e811f522..a55c3365 100644
--- a/api/src/util/Message.ts
+++ b/api/src/util/Message.ts
@@ -1,14 +1,14 @@
-import { ChannelModel, Embed, Message, MessageCreateEvent, MessageUpdateEvent } from "@fosscord/server-util";
-import { Snowflake } from "@fosscord/server-util";
-import { MessageModel } from "@fosscord/server-util";
-import { PublicMemberProjection } from "@fosscord/server-util";
-import { toObject } from "@fosscord/server-util";
-import { getPermission } from "@fosscord/server-util";
+import { ChannelModel, Embed, emitEvent, Message, MessageCreateEvent, MessageUpdateEvent } from "@fosscord/util";
+import { Snowflake } from "@fosscord/util";
+import { MessageModel } from "@fosscord/util";
+import { PublicMemberProjection } from "@fosscord/util";
+import { toObject } from "@fosscord/util";
+import { getPermission } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import fetch from "node-fetch";
 import cheerio from "cheerio";
-import { emitEvent } from "./Event";
-import { MessageType } from "@fosscord/server-util/dist/util/Constants";
+
+import { MessageType } from "@fosscord/util/dist/util/Constants";
 // TODO: check webhook, application, system author
 
 const LINK_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
diff --git a/api/src/util/User.ts b/api/src/util/User.ts
index 107fc759..392c7101 100644
--- a/api/src/util/User.ts
+++ b/api/src/util/User.ts
@@ -1,4 +1,4 @@
-import { toObject, UserModel, PublicUserProjection } from "@fosscord/server-util";
+import { toObject, UserModel, PublicUserProjection } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 
 export { PublicUserProjection };
diff --git a/api/src/util/cdn.ts b/api/src/util/cdn.ts
index aed8ca0a..3c71d980 100644
--- a/api/src/util/cdn.ts
+++ b/api/src/util/cdn.ts
@@ -1,4 +1,4 @@
-import { Config } from "@fosscord/server-util";
+import { Config } from "@fosscord/util";
 import FormData from "form-data";
 import { HTTPError } from "lambert-server";
 import fetch from "node-fetch";
diff --git a/api/src/util/ipAddress.ts b/api/src/util/ipAddress.ts
index f2c8fd4d..0a724daa 100644
--- a/api/src/util/ipAddress.ts
+++ b/api/src/util/ipAddress.ts
@@ -1,4 +1,4 @@
-import { Config } from "@fosscord/server-util";
+import { Config } from "@fosscord/util";
 import { Request } from "express";
 // use ipdata package instead of simple fetch because of integrated caching
 import fetch from "node-fetch";
diff --git a/api/src/util/passwordStrength.ts b/api/src/util/passwordStrength.ts
index cc503843..dfffa2c0 100644
--- a/api/src/util/passwordStrength.ts
+++ b/api/src/util/passwordStrength.ts
@@ -1,4 +1,4 @@
-import { Config } from "@fosscord/server-util";
+import { Config } from "@fosscord/util";
 import "missing-native-js-functions";
 
 const reNUMBER = /[0-9]/g;