From 4f5d605011dcefbc1c5e7c77fa2cf75bf7a0a80c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sat, 9 Dec 2017 00:43:37 +0100 Subject: [PATCH] Fixed the previous packaging: `RequestEvent` class released by error --- lib/client.js | 34 ++++------------------------------ lib/index.js | 5 ++--- package.json | 2 +- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/lib/client.js b/lib/client.js index 04f96243..1ce1c3b9 100644 --- a/lib/client.js +++ b/lib/client.js @@ -122,8 +122,8 @@ exports.Client = class Client extends EventEmitter { * @param {URL} endPoint The URL of the end point to query. * @param {object} fields The fields describing the query body. * @return {Promise} The response as string. - * @emits {RequestEvent} The "request" event. - * @emits {RequestEvent} The "response" event. + * @emits {Request} The "request" event. + * @emits {Reponse} The "response" event. */ async _fetch(endPoint, fields) { let body = new URLSearchParams(Object.assign(this.blog.toJSON(), fields)); @@ -135,38 +135,12 @@ exports.Client = class Client extends EventEmitter { body }); - this.emit('request', new exports.RequestEvent(req)); + this.emit('request', req); let res = await fetch(req); - this.emit('response', new exports.RequestEvent(req, res)); + this.emit('response', req, res); if (!res.ok) throw new Error('An error occurred while querying the end point.'); if (res.headers.has(Client.debugHeader)) throw new Error(res.headers.get(Client.debugHeader)); return res.text(); } }; - -/** - * The event parameter used for request events. - */ -exports.RequestEvent = class RequestEvent { - - /** - * Initializes a new instance of the class. - * @param {Request} request The client request. - * @param {Response} [response] The server response. - */ - constructor(request, response = null) { - - /** - * The client request. - * @type {Request} - */ - this.request = request; - - /** - * The server response. - * @type {Response} - */ - this.response = response; - } -}; diff --git a/lib/index.js b/lib/index.js index 6fb67b31..53cf95cd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,7 +2,7 @@ const {Author} = require('./author'); const {Blog} = require('./blog'); -const {Client, RequestEvent} = require('./client'); +const {Client} = require('./client'); const {Comment, CommentType} = require('./comment'); module.exports = { @@ -10,6 +10,5 @@ module.exports = { Blog, Client, Comment, - CommentType, - RequestEvent + CommentType }; diff --git a/package.json b/package.json index a3f5db70..ed2d4d9b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "main": "./lib/index.js", "name": "@cedx/akismet", "repository": "cedx/akismet.js", - "version": "13.0.0", + "version": "13.0.1", "dependencies": { "node-fetch": "^1.7.3" },