Created
November 1, 2021 06:42
-
-
Save Carlos-Augusto/d10ade16400cfea5ae8dcf371f236cd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const fetch = require('node-fetch'); | |
const https = require('https'); | |
const fs = require('fs'); | |
const pfx_file = fs.readFileSync(__dirname + "/PFX.pfx"); | |
const ping = async (stage) => { | |
if (stage === "") { | |
throw new Error("Stage can't be empty.") | |
} | |
const httpsAgent = new https.Agent({ | |
keepAlive: true, | |
pfx: pfx_file, | |
passphrase: "PASSPHRASE" | |
}); | |
const url = "https://api.certify." + stage + ".ubirch.com" | |
const resp = await fetch(url, { | |
method: 'get', | |
agent: (_parsedURL) => { | |
return httpsAgent; | |
} | |
}); | |
if (resp.status > 299) { | |
throw Error("response_status=" + resp.status); | |
} | |
return resp.buffer(); | |
}; | |
module.exports = {ping: ping}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment