gl-store-s3.js/index.js

72 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-05-08 23:01:23 +00:00
var path = require("path");
var Promise = require("bluebird");
2019-05-08 13:05:05 +00:00
2019-05-08 23:01:23 +00:00
const AWS = require("aws-sdk");
2019-05-08 13:05:05 +00:00
AWS.config.setPromisesDependency(Promise);
const defaultOptions = {
accessKeyId: null
, secretAccessKey: null
, bucketName: null
, bucketRegion: null
2019-05-08 23:01:23 +00:00
, accountsDir: "accounts/"
, configDir: "acme/"
2019-05-08 23:12:15 +00:00
};
2019-05-08 13:05:05 +00:00
2019-05-08 23:01:23 +00:00
const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
2019-05-08 13:05:05 +00:00
2019-05-08 23:01:23 +00:00
const pathHelper = require("./lib/pathHelper");
const fileNames = require("./lib/fileNames");
2019-05-08 14:37:55 +00:00
2019-05-08 13:05:05 +00:00
module.exports.create = (createOptions) => {
const options = Object.assign({}, defaultOptions, createOptions);
2019-05-08 13:15:46 +00:00
if (!options.debug) {
console = console || {};
console.log = () => { };
console.error = () => { };
}
2019-05-08 13:05:05 +00:00
AWS.config.update({
region: options.bucketRegion
, credentials: new AWS.Credentials({
accessKeyId: options.accessKeyId
, secretAccessKey: options.secretAccessKey
})
});
const handlers = {
certificates: {
check: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/certificates/check").check(opts, options, s3);
2019-05-08 13:05:05 +00:00
},
checkKeypair: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/certificates/checkKeypair").checkKeypair(opts, options, s3);
2019-05-08 13:05:05 +00:00
},
setKeypair: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/certificates/setKeypair").setKeypair(opts, options, s3);
2019-05-08 13:05:05 +00:00
},
set: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/certificates/set").set(opts, options, s3);
2019-05-08 13:05:05 +00:00
}
},
accounts: {
check: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/accounts/check").check(opts, options, s3);
2019-05-08 13:05:05 +00:00
},
checkKeypair: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/accounts/checkKeypair").checkKeypair(opts, options, s3);
2019-05-08 13:05:05 +00:00
},
setKeypair: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/accounts/setKeypair").setKeypair(opts, options, s3);
2019-05-08 13:05:05 +00:00
},
set: (opts) => {
2019-05-08 23:01:23 +00:00
return require("./lib/accounts/set").set(opts, options, s3);
2019-05-08 13:05:05 +00:00
}
}
2019-05-09 07:36:47 +00:00
};
2019-05-08 13:05:05 +00:00
return handlers;
2019-05-08 23:12:15 +00:00
};