2
0
mirror of https://github.com/cderche/greenlock-storage-s3 synced 2025-02-22 06:08:04 +00:00

getPromises()

This commit is contained in:
Cyrille 2019-05-09 22:16:52 +01:00
parent 0f5eebd9cc
commit 8e38a11e46

View File

@ -3,7 +3,7 @@ const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
const pathHelper = require("../pathHelper"); const pathHelper = require("../pathHelper");
const fileNames = require("../fileNames"); const fileNames = require("../fileNames");
const setPaths = (opts, options, id) => { const getPaths = (opts, options, id) => {
return [ return [
pathHelper.certificatesPath(options, id, fileNames.privkey.pem) pathHelper.certificatesPath(options, id, fileNames.privkey.pem)
, pathHelper.certificatesPath(options, id, fileNames.cert) , pathHelper.certificatesPath(options, id, fileNames.cert)
@ -11,13 +11,8 @@ const setPaths = (opts, options, id) => {
] ]
}; };
module.exports.check = (opts, options) => { const getPromises = (options, paths) => {
const id = opts.certificate && opts.certificate.id || opts.subject; let promises = [];
console.log("certificates.check for", opts.subject);
const paths = setPaths(opts, options, id);
var promises = [];
for (let i = 0; i < paths.length; i++) { for (let i = 0; i < paths.length; i++) {
const key = paths[i]; const key = paths[i];
@ -31,6 +26,16 @@ module.exports.check = (opts, options) => {
promises.push(promise); promises.push(promise);
} }
return promises;
}
module.exports.check = (opts, options) => {
const id = opts.certificate && opts.certificate.id || opts.subject;
console.log("certificates.check for", opts.subject);
const paths = getPaths(opts, options, id);
const promises = getPromises(options, paths);
return Promise.all(promises).then((values) => { return Promise.all(promises).then((values) => {
return { return {
privkey: values[0] privkey: values[0]