update script

This commit is contained in:
deityhub
2021-06-22 14:47:04 +01:00
parent 10e1c1d454
commit 2f1c26dfd7
3 changed files with 7549 additions and 7527 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,7 @@
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"moment": "^2.29.1",
"mongodb": "^3.5.2",
"nanoid": "^1.3.0",
"slugify": "^1.4.7",

View File

@@ -1,4 +1,5 @@
const { find, save } = require('../util/db');
const moment = require('moment');
const statusPageCollection = 'statuspages';
const siteManagerCollection = 'sitemanagers';
@@ -12,21 +13,25 @@ async function run() {
});
for (const statusPage of statusPages) {
const domains = statusPage.domains
const currentDate = new Date(moment().format());
const domainsToSave = statusPage.domains
.filter(
domainObj => domainObj.enableHttps && domainObj.autoProvisioning
domainObj =>
domainObj.enableHttps &&
domainObj.autoProvisioning &&
domainObj.domain
)
.map(domainObj => domainObj.domain);
for (const domain of domains) {
// default renewAt to 1
// cert should be renewed within 24 hours
await save(siteManagerCollection, {
subject: domain,
altnames: [domain],
.map(domainObj => ({
subject: domainObj.domain,
altnames: [domainObj.domain],
renewAt: 1,
});
}
createdAt: currentDate,
updatedAt: currentDate,
}));
// default renewAt to 1
// cert should be renewed within 24 hours
await save(siteManagerCollection, domainsToSave);
}
return `Script ran for ${statusPages.length} status pages`;