From 10c40d598ced43509c92ed7bb8fe494fcdf70e6d Mon Sep 17 00:00:00 2001 From: Raunak Gurud Date: Wed, 31 Jan 2024 11:24:26 +0530 Subject: [PATCH] refactor: #9 --- dist/index.js | 13 ++++--------- src/controller/index.ts | 7 +------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8e71f73..d2aed6d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -27,7 +27,7 @@ const axios_1 = __importDefault(__nccwpck_require__(8757)); const api_1 = __nccwpck_require__(2895); const constants_1 = __nccwpck_require__(5105); const publishBlog = async (hashnode_key, article, host) => { - var _a, _b, _c, _d, _e, _f, _g; + var _a, _b, _c; const toPublish = (_a = article.data.publish) !== null && _a !== void 0 ? _a : false; // get publicationId const { publication, error } = await (0, exports.getPublicationId)(host); @@ -72,12 +72,7 @@ const publishBlog = async (hashnode_key, article, host) => { }); return { data: data.data, - error: { - status_code: (_c = (_b = data === null || data === void 0 ? void 0 : data.errors[0]) === null || _b === void 0 ? void 0 : _b.extensions.code) !== null && _c !== void 0 ? _c : null, - // message: JSON.stringify(data), - message: ((_d = data === null || data === void 0 ? void 0 : data.errors[0]) === null || _d === void 0 ? void 0 : _d.message) || null, - info: ((_e = data === null || data === void 0 ? void 0 : data.errors[0]) === null || _e === void 0 ? void 0 : _e.extensions) || null, - }, + error: data.error, }; } catch (error) { @@ -87,10 +82,10 @@ const publishBlog = async (hashnode_key, article, host) => { error: { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - status_code: (_f = error === null || error === void 0 ? void 0 : error.errors[0].extensions) === null || _f === void 0 ? void 0 : _f.code, + status_code: (_b = error === null || error === void 0 ? void 0 : error.errors[0].extensions) === null || _b === void 0 ? void 0 : _b.code, // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - message: JSON.stringify((_g = error === null || error === void 0 ? void 0 : error.errors[0]) === null || _g === void 0 ? void 0 : _g.message), + message: JSON.stringify((_c = error === null || error === void 0 ? void 0 : error.errors[0]) === null || _c === void 0 ? void 0 : _c.message), }, }; } diff --git a/src/controller/index.ts b/src/controller/index.ts index d1138c7..64327fc 100644 --- a/src/controller/index.ts +++ b/src/controller/index.ts @@ -73,12 +73,7 @@ export const publishBlog = async ( return { data: data.data, - error: { - status_code: data?.errors[0]?.extensions.code ?? null, - // message: JSON.stringify(data), - message: data?.errors[0]?.message || null, - info: data?.errors[0]?.extensions || null, - }, + error: data.error, }; } catch (error) { console.log(error);