fix: getaddrinfo ENOTFOUND while creating admin

This commit is contained in:
prafull-opensignlabs
2024-07-30 16:53:36 +05:30
parent 44754095fb
commit 299648b8e0
32 changed files with 99 additions and 52 deletions
@@ -2,6 +2,7 @@ import axios from 'axios';
import { google } from 'googleapis';
import fs from 'node:fs';
import https from 'https';
import http from 'http';
const clientId = process.env.GOOGLE_CLIENT_ID;
const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
// Function to create a Gmail client
@@ -34,10 +35,17 @@ const makeEmail = async (to, from, subject, html, url, pdfName) => {
let Pdf = fs.createWriteStream('test.pdf');
const writeToLocalDisk = () => {
return new Promise((resolve, reject) => {
https.get(url, async function (response) {
response.pipe(Pdf);
response.on('end', () => resolve('success'));
});
if (useLocal !== 'true') {
https.get(url, async function (response) {
response.pipe(Pdf);
response.on('end', () => resolve('success'));
});
} else {
http.get(url, async function (response) {
response.pipe(Pdf);
response.on('end', () => resolve('success'));
});
}
});
};
// `writeToLocalDisk` is used to create pdf file from doc url
@@ -130,7 +138,7 @@ export default async function sendMailGmailProvider(_extRes, template) {
raw: email,
},
});
// console.log('response ', response);
// console.log('response ', response);
return { code: 200, message: 'Email sent successfully' };
} catch (error) {