From 214e00d2917439b55ea1d5e0a122b73d94265e1c Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 6 May 2023 23:17:10 +0300 Subject: [PATCH] fix registration again --- package.json | 2 +- src/controller/Controller.ts | 8 +++++--- src/controller/Shard.ts | 6 ++++-- src/server/endpoints/api/Register.ts | 3 +-- src/server/interfaces/ApiEndpoint.ts | 2 +- src/server/middleware/Authenticator.ts | 4 ++-- yarn.lock | 10 +++++----- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index b5481d3..4845a7d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@discordjs/collection": "^1.2.0", - "@navy.gif/commandparser": "^1.4.3", + "@navy.gif/commandparser": "^1.4.5", "@navy.gif/logger": "^2.3.3", "@navy.gif/passport-discord": "^0.2.2-b", "@navy.gif/wrappers": "^1.3.9", diff --git a/src/controller/Controller.ts b/src/controller/Controller.ts index 3ce0d57..d1490da 100644 --- a/src/controller/Controller.ts +++ b/src/controller/Controller.ts @@ -191,9 +191,11 @@ class Controller extends EventEmitter { const { command, ...rest } = result; - if (rest.args.help) - // return this.#_logger.info(`COMMAND HELP\n${command.help}`); - return this.#_logger.info(`Command help unavailable at this time`); + if (rest.args.help) { + if (command.help) + return command.help; + return this.#_logger.info(`Help for ${command.name} unavailable at this time`); + } let response = null; try { diff --git a/src/controller/Shard.ts b/src/controller/Shard.ts index 09fa175..920c291 100644 --- a/src/controller/Shard.ts +++ b/src/controller/Shard.ts @@ -245,8 +245,10 @@ class Shard extends EventEmitter { if (this.#_awaitingShutdown) this.#_awaitingShutdown(); - if (code !== 0) - this.#_crashes.push(Date.now() - this.spawnedAt); + if (code !== 0) { + this.#_crashes.push(Date.now() - this.spawnedAt); + this.emit('warn', `Shard exited with non-zero exit code`); + } this.#_ready = false; this.#_process = null; diff --git a/src/server/endpoints/api/Register.ts b/src/server/endpoints/api/Register.ts index cd5644d..5eabcc9 100644 --- a/src/server/endpoints/api/Register.ts +++ b/src/server/endpoints/api/Register.ts @@ -16,8 +16,7 @@ class RegisterEndpoint extends ApiEndpoint { super(server, { name: 'register', - path: '/register', - auth: true + path: '/register' }); this.methods = [ diff --git a/src/server/interfaces/ApiEndpoint.ts b/src/server/interfaces/ApiEndpoint.ts index 0d142f7..c8e5093 100644 --- a/src/server/interfaces/ApiEndpoint.ts +++ b/src/server/interfaces/ApiEndpoint.ts @@ -15,7 +15,7 @@ class ApiEndpoint extends Endpoint { path: `/api${opts.path}` }); - // this._middleware.push(this.rateLimiter.throttle({ limit: 5, time: 5, path: this.path.replace(opts.path, ''), endpoint: this })); + // this._middleware.push(this.rateLimiter.throttle({ limit: 5, time: 1, path: this.path.replace(opts.path, ''), endpoint: this })); } diff --git a/src/server/middleware/Authenticator.ts b/src/server/middleware/Authenticator.ts index 2483fcb..448aba4 100644 --- a/src/server/middleware/Authenticator.ts +++ b/src/server/middleware/Authenticator.ts @@ -13,7 +13,7 @@ import { LoggerClient } from '@navy.gif/logger'; import session from 'express-session'; import passport from "passport"; import MongoStore from "connect-mongo"; -import { AuthFunction, Request, Response } from "../../../@types/Server.js"; +import { MiddlewareFunction, Request, Response } from "../../../@types/Server.js"; import { NextFunction } from "express"; import { User } from "../structures/index.js"; @@ -38,7 +38,7 @@ type OAuthParams = { */ class Authenticator { - [key: string]: AuthFunction | unknown + [key: string]: MiddlewareFunction | unknown #_userdb: UserDatabaseInterface; #_cookieName: string; diff --git a/yarn.lock b/yarn.lock index bfa95b4..b30e13d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1737,10 +1737,10 @@ __metadata: languageName: node linkType: hard -"@navy.gif/commandparser@npm:^1.4.3": - version: 1.4.3 - resolution: "@navy.gif/commandparser@npm:1.4.3" - checksum: edfd9c82be3497f4eb196ef67dcdf3a4c602df33653e2b9a81cad083271c2df21345a1a5d333f107258527741bde133c29a6a145fb5d81809a1d2c6ddf25c284 +"@navy.gif/commandparser@npm:^1.4.5": + version: 1.4.5 + resolution: "@navy.gif/commandparser@npm:1.4.5" + checksum: d41e6742401e9a5559cc146ee7ce5e511e08050d498e735b5a864e48f5e49f4dcfd10ac8d782db5efe9e010adcaf5e0d44f69bfba08f803518ff43ad467263cb languageName: node linkType: hard @@ -7035,7 +7035,7 @@ __metadata: "@babel/core": ^7.20.12 "@babel/preset-env": ^7.20.2 "@discordjs/collection": ^1.2.0 - "@navy.gif/commandparser": ^1.4.3 + "@navy.gif/commandparser": ^1.4.5 "@navy.gif/logger": ^2.3.3 "@navy.gif/passport-discord": ^0.2.2-b "@navy.gif/wrappers": ^1.3.9