Skip to content

Commit

Permalink
refactor: #8
Browse files Browse the repository at this point in the history
  • Loading branch information
raunakgurud09 committed Jan 31, 2024
1 parent 3433a58 commit 1868f2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 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;
var _a, _b, _c, _d, _e, _f, _g;
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 @@ -73,10 +73,10 @@ const publishBlog = async (hashnode_key, article, host) => {
return {
data: data.data,
error: {
status_code: 400,
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: data.errors[0].message,
info: data.errors[0].extensions,
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,
},
};
}
Expand All @@ -87,10 +87,10 @@ const publishBlog = async (hashnode_key, article, host) => {
error: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
status_code: (_b = error === null || error === void 0 ? void 0 : error.errors[0].extensions) === null || _b === void 0 ? void 0 : _b.code,
status_code: (_f = error === null || error === void 0 ? void 0 : error.errors[0].extensions) === null || _f === void 0 ? void 0 : _f.code,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
message: JSON.stringify((_c = error === null || error === void 0 ? void 0 : error.errors[0]) === null || _c === void 0 ? void 0 : _c.message),
message: JSON.stringify((_g = error === null || error === void 0 ? void 0 : error.errors[0]) === null || _g === void 0 ? void 0 : _g.message),
},
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export const publishBlog = async (
return {
data: data.data,
error: {
status_code: 400,
status_code: data?.errors[0]?.extensions.code ?? null,
// message: JSON.stringify(data),
message: data.errors[0].message,
info: data.errors[0].extensions,
message: data?.errors[0]?.message || null,
info: data?.errors[0]?.extensions || null,
},
};
} catch (error) {
Expand Down

0 comments on commit 1868f2c

Please sign in to comment.