nestjs-appwrite
Version:
Easier Appwrite integration for your NestJS application.
56 lines (55 loc) • 2.54 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var ParameterStoreService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParameterStoreService = void 0;
const common_1 = require("@nestjs/common");
const client_ssm_1 = require("@aws-sdk/client-ssm");
const secret_store_service_1 = require("./secret-store.service");
const appwrite_constants_1 = require("../appwrite.constants");
let ParameterStoreService = ParameterStoreService_1 = class ParameterStoreService extends secret_store_service_1.SecretStoreService {
constructor(config) {
super();
this.config = config;
this.logger = new common_1.Logger(ParameterStoreService_1.name);
}
async getSecretString(secretName) {
try {
const serviceAccount = await this.getSsmClient().send(new client_ssm_1.GetParameterCommand({
Name: secretName,
WithDecryption: true
}));
return serviceAccount.Parameter?.Value;
}
catch (err) {
this.logger.error(err);
return undefined;
}
}
getSsmClient() {
if (this.client) {
return this.client;
}
this.client = new client_ssm_1.SSMClient({
region: this.config.AWS_REGION,
});
return this.client;
}
};
exports.ParameterStoreService = ParameterStoreService;
exports.ParameterStoreService = ParameterStoreService = ParameterStoreService_1 = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)(appwrite_constants_1.CONFIG_PROVIDER_NAME)),
__metadata("design:paramtypes", [Object])
], ParameterStoreService);