Skip to content

Commit

Permalink
refactor: #9
Browse files Browse the repository at this point in the history
  • Loading branch information
raunakgurud09 committed Jan 31, 2024
1 parent 1868f2c commit 10c40d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
13 changes: 4 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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),
},
};
}
Expand Down
7 changes: 1 addition & 6 deletions src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 10c40d5

Please sign in to comment.