From 26d4b68632d2797f543a240e34455371371c8766 Mon Sep 17 00:00:00 2001 From: Aura Date: Sun, 21 Jul 2024 20:20:24 +0200 Subject: [PATCH] fix(deps): update `@vladfrangu/async_event_emitter` (#596) --- packages/api/package.json | 2 +- packages/api/src/lib/structures/http/Server.ts | 2 +- .../src/listeners/PluginServerMiddlewareSuccess.ts | 2 +- packages/api/src/listeners/PluginServerRequest.ts | 4 ++-- packages/api/src/listeners/PluginServerRouterFound.ts | 3 ++- yarn.lock | 11 +++++++++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index a16740c2..cc94e4ee 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -51,7 +51,7 @@ }, "dependencies": { "@types/ws": "^8.5.10", - "@vladfrangu/async_event_emitter": "2.4.1", + "@vladfrangu/async_event_emitter": "2.4.4", "tldts": "^6.1.31", "undici": "^6.19.2" }, diff --git a/packages/api/src/lib/structures/http/Server.ts b/packages/api/src/lib/structures/http/Server.ts index a197589f..1081dc3a 100644 --- a/packages/api/src/lib/structures/http/Server.ts +++ b/packages/api/src/lib/structures/http/Server.ts @@ -30,7 +30,7 @@ export interface ServerEvents { [ServerEvent.RouterBranchMethodNotAllowed]: [request: ApiRequest, response: ApiResponse, node: RouterBranch]; [ServerEvent.RouterFound]: [request: ApiRequest, response: ApiResponse]; [ServerEvent.RouteError]: [error: Error, request: ApiRequest, response: ApiResponse]; - [ServerEvent.MiddlewareFailure]: [error: Error, request: ApiRequest, response: ApiResponse]; + [ServerEvent.MiddlewareFailure]: [request: ApiRequest, response: ApiResponse]; [ServerEvent.MiddlewareSuccess]: [request: Route.Request, response: Route.Response, route: Route]; [ServerEvent.MiddlewareError]: [error: Error, request: ApiRequest, response: ApiResponse]; } diff --git a/packages/api/src/listeners/PluginServerMiddlewareSuccess.ts b/packages/api/src/listeners/PluginServerMiddlewareSuccess.ts index b6ca2266..360fa80c 100644 --- a/packages/api/src/listeners/PluginServerMiddlewareSuccess.ts +++ b/packages/api/src/listeners/PluginServerMiddlewareSuccess.ts @@ -12,7 +12,7 @@ export class PluginListener extends Listener { try { await request.route!.run(request, response); } catch (error) { - this.container.server.emit(ServerEvent.RouteError, error, request, response); + this.container.server.emit(ServerEvent.RouteError, error as Error, request, response); } } } diff --git a/packages/api/src/listeners/PluginServerRequest.ts b/packages/api/src/listeners/PluginServerRequest.ts index be1f9b11..a4548253 100644 --- a/packages/api/src/listeners/PluginServerRequest.ts +++ b/packages/api/src/listeners/PluginServerRequest.ts @@ -29,7 +29,7 @@ export class PluginListener extends Listener { // Middlewares need to be run regardless of the match, specially since browsers do an OPTIONS request first. await this.container.server.middlewares.run(request, response); } catch (error) { - this.container.server.emit(ServerEvent.MiddlewareError, error, request, response); + this.container.server.emit(ServerEvent.MiddlewareError, error as Error, request, response); // If a middleware errored, it might cause undefined behavior in the routes, so we will return early. return; @@ -38,7 +38,7 @@ export class PluginListener extends Listener { if (branch === null) { this.container.server.emit(ServerEvent.RouterBranchNotFound, request, response); } else if (route === null) { - this.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response); + this.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response, branch); } else { this.container.server.emit(ServerEvent.RouterFound, request, response); } diff --git a/packages/api/src/listeners/PluginServerRouterFound.ts b/packages/api/src/listeners/PluginServerRouterFound.ts index 819c28a7..c2887931 100644 --- a/packages/api/src/listeners/PluginServerRouterFound.ts +++ b/packages/api/src/listeners/PluginServerRouterFound.ts @@ -9,6 +9,7 @@ export class PluginListener extends Listener { } public override run(request: ApiRequest, response: ApiResponse) { - this.container.server.emit(response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess, request, response); + const event = response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess; + this.container.server.emit(event, request, response); } } diff --git a/yarn.lock b/yarn.lock index 29988e71..91c1301c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1178,7 +1178,7 @@ __metadata: "@favware/cliff-jumper": "npm:^4.0.2" "@favware/rollup-type-bundler": "npm:^3.3.0" "@types/ws": "npm:^8.5.10" - "@vladfrangu/async_event_emitter": "npm:2.4.1" + "@vladfrangu/async_event_emitter": "npm:2.4.4" concurrently: "npm:^8.2.2" tldts: "npm:^6.1.31" tsup: "npm:^8.1.0" @@ -1684,7 +1684,14 @@ __metadata: languageName: node linkType: hard -"@vladfrangu/async_event_emitter@npm:2.4.1, @vladfrangu/async_event_emitter@npm:^2.2.4": +"@vladfrangu/async_event_emitter@npm:2.4.4": + version: 2.4.4 + resolution: "@vladfrangu/async_event_emitter@npm:2.4.4" + checksum: 10/634c2d656fb3a3b47584865b5bf2b92f06f19a0018324340c29f2215a82fc96b4997dc2a78c6aeefcb29b6b2f8c03e8f06234b45965b706f7bde5b997b7d8be2 + languageName: node + linkType: hard + +"@vladfrangu/async_event_emitter@npm:^2.2.4": version: 2.4.1 resolution: "@vladfrangu/async_event_emitter@npm:2.4.1" checksum: 10/f8212e81c56d4994b1d5bf23f66bb47d4254c80f1dee7437a411a0b9cd942ae53bb3f21400590c3c70121b299457a77241535567a1de35822a35044740ccb48e