fix(backend): run prettier and yarn add node-forge

Signed-off-by: Johannes Grumboeck <johannes@grumboeck.net>
This commit is contained in:
Johannes Grumboeck
2022-10-14 00:54:28 +02:00
parent 7e739e6009
commit 35f292c9f7
3 changed files with 6 additions and 4 deletions
+1
View File
@@ -75,6 +75,7 @@
"morgan": "^1.10.0",
"node-abort-controller": "^3.0.1",
"node-fetch": "^2.6.7",
"node-forge": "^1.3.1",
"raw-body": "^2.4.1",
"request": "^2.88.2",
"selfsigned": "^2.0.0",
@@ -99,17 +99,17 @@ async function getGeneratedCertificate(hostname: string, logger?: Logger) {
if (await fs.pathExists(certPath)) {
cert = await fs.readFile(certPath);
try {
const forge = require('node-forge')
const crt = forge.pki.certificateFromPem(cert)
const forge = require('node-forge');
const crt = forge.pki.certificateFromPem(cert);
const crtTimestamp = Date.parse(crt.validity.notAfter);
remainingMs = crtTimestamp - Date.now();
} catch (error) {
logger?.warn(`Unable to parse self-signed certificate. ${error}`);
remainingMs = 0
remainingMs = 0;
}
if (remainingMs < FIVE_DAYS_IN_MS) {
// Reset certificate if expiration is nearly over
cert = undefined
cert = undefined;
}
}