@janiscommerce/client-creator
Version:
A package that wraps all the client creation in Janis Services
37 lines (24 loc) • 696 B
JavaScript
;
const {
SSMClient,
GetParameterCommand
} = require('@aws-sdk/client-ssm');
const logger = require('lllog')();
module.exports = class ParameterStore {
static get parameterName() {
return `${process.env.JANIS_SERVICE_NAME}-databases`;
}
static async set() {
this.parameter = {};
try {
const ssmClient = new SSMClient();
const response = await ssmClient.send(new GetParameterCommand({ Name: this.parameterName }));
this.parameter = JSON.parse(response.Parameter.Value).newClientsDatabases;
} catch(error) {
logger.error(`Unable to get ParameterStore ${this.parameterName} - ${error.message}`);
}
}
static get() {
return this.parameter;
}
};