diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-17 22:42:16 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-17 22:42:16 +0200 |
commit | e611126c7c168b7c14e6d79fe02e1f996937bbfc (patch) | |
tree | ffe0135fdf4ca7ae9b9005bbb85a6689345a06c2 | |
parent | :sparkles: mention regex (diff) | |
download | server-e611126c7c168b7c14e6d79fe02e1f996937bbfc.tar.xz |
:art: clean up
-rw-r--r-- | .github/workflows/release.yml | 5 | ||||
-rw-r--r-- | api/package-lock.json | 4 | ||||
-rw-r--r-- | api/src/middlewares/Authentication.ts | 7 | ||||
-rw-r--r-- | api/src/routes/auth/login.ts | 1 | ||||
-rw-r--r-- | bundle/src/Server.ts | 5 | ||||
-rw-r--r-- | bundle/src/stats.ts | 1 | ||||
-rw-r--r-- | util/src/util/Config.ts | 4 | ||||
-rw-r--r-- | util/src/util/Event.ts | 5 |
8 files changed, 13 insertions, 19 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af6f35ee..e0bb5e33 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,11 +65,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Extract version - id: extract_version - uses: Saionaro/extract-package-version@v1.1.1 - with: - path: api - uses: actions/download-artifact@v2 with: name: fosscord-server-windows.exe diff --git a/api/package-lock.json b/api/package-lock.json index d94e3be0..00af4b5b 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -43,6 +43,7 @@ "@types/i18next-node-fs-backend": "^2.1.0", "@types/jsonwebtoken": "^8.5.0", "@types/mongodb": "^3.6.9", + "@types/mongoose": "^5.10.5", "@types/mongoose-autopopulate": "^0.10.1", "@types/mongoose-lean-virtuals": "^0.5.1", "@types/multer": "^1.4.5", @@ -60,7 +61,8 @@ } }, "../util": { - "version": "1.3.55", + "name": "@fosscord/util", + "version": "1.0.0", "hasInstallScript": true, "license": "GPLV3", "dependencies": { diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts index 06eeab39..a8bfe196 100644 --- a/api/src/middlewares/Authentication.ts +++ b/api/src/middlewares/Authentication.ts @@ -27,11 +27,12 @@ declare global { export async function Authentication(req: Request, res: Response, next: NextFunction) { if (req.method === "OPTIONS") return res.sendStatus(204); - if (req.url.startsWith("/invites") && req.method === "GET") return next(); // @ts-ignore + const url = req.url.replace(API_PREFIX, ""); + if (url.startsWith("/invites") && req.method === "GET") return next(); // @ts-ignore if ( NO_AUTHORIZATION_ROUTES.some((x) => { - if (typeof x === "string") return req.url.startsWith(x); - return x.test(req.url); + if (typeof x === "string") return url.startsWith(x); + return x.test(url); }) ) return next(); diff --git a/api/src/routes/auth/login.ts b/api/src/routes/auth/login.ts index a7247485..dc970e4c 100644 --- a/api/src/routes/auth/login.ts +++ b/api/src/routes/auth/login.ts @@ -4,7 +4,6 @@ import bcrypt from "bcrypt"; import jwt from "jsonwebtoken"; import { Config, UserModel } from "@fosscord/util"; import { adjustEmail } from "./register"; -import RateLimit from "../../middlewares/RateLimit"; const router: Router = Router(); export default router; diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts index c6acf0ad..e0586601 100644 --- a/bundle/src/Server.ts +++ b/bundle/src/Server.ts @@ -33,9 +33,8 @@ async function main() { }, }); - await api.start(); - await cdn.start(); - await gateway.start(); + await Promise.all([api.start(), cdn.start(), gateway.start()]); + console.log(`[Server] listening on port ${port}`); } main().catch(console.error); diff --git a/bundle/src/stats.ts b/bundle/src/stats.ts index 6413f347..37ddb4e2 100644 --- a/bundle/src/stats.ts +++ b/bundle/src/stats.ts @@ -2,6 +2,7 @@ import os from "os"; import osu from "node-os-utils"; export function initStats() { + console.log(`[Path] running in ${__dirname}`); console.log(`[CPU] ${osu.cpu.model()} Cores x${osu.cpu.count()}`); console.log(`[System] ${os.platform()} ${os.arch()}`); console.log(`[Database] started`); diff --git a/util/src/util/Config.ts b/util/src/util/Config.ts index ec1efc6c..a93e1846 100644 --- a/util/src/util/Config.ts +++ b/util/src/util/Config.ts @@ -211,11 +211,11 @@ export const DefaultOptions: DefaultOptions = { }, webhook: { count: 5, - window: 5, + window: 20, }, channel: { count: 5, - window: 5, + window: 20, }, auth: { login: { diff --git a/util/src/util/Event.ts b/util/src/util/Event.ts index 53e74c5f..0dbddc76 100644 --- a/util/src/util/Event.ts +++ b/util/src/util/Event.ts @@ -6,7 +6,7 @@ const events = new EventEmitter(); export async function emitEvent(payload: Omit<Event, "created_at">) { const id = (payload.channel_id || payload.user_id || payload.guild_id) as string; - if (!id) console.error("event doesn't contain any id", payload); + if (!id) return console.error("event doesn't contain any id", payload); if (RabbitMQ.connection) { const data = typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.data; // use rabbitmq for event transmission @@ -16,7 +16,6 @@ export async function emitEvent(payload: Omit<Event, "created_at">) { const successful = RabbitMQ.channel?.publish(id, "", Buffer.from(`${data}`), { type: payload.event }); if (!successful) throw new Error("failed to send event"); } else { - console.log("emit event", id); events.emit(id, payload); } } @@ -46,10 +45,8 @@ export async function listenEvent(event: string, callback: (event: EventOpts) => return rabbitListen(opts?.channel || RabbitMQ.channel, event, callback, { acknowledge: opts?.acknowledge }); } else { const cancel = () => { - console.log("cancel event", event); events.removeListener(event, callback); }; - console.log("listen event", event); events.addListener(event, (opts) => callback({ ...opts, cancel })); return cancel; |