UNPKG

@xmotion/aws-ssm-param-nestjs

Version:

AWS SSM Parameter Store Helper on NestJS application

55 lines (54 loc) 2.55 kB
"use strict"; 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 ConfigParametersService_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigParametersService = void 0; const common_1 = require("@nestjs/common"); const constants_1 = require("../constants"); let ConfigParametersService = class ConfigParametersService { static { ConfigParametersService_1 = this; } configParameters; static trutyValues = ['true', 'True', '1', 'y', 'yes', 'Yes']; constructor(configParameters) { this.configParameters = configParameters; } get(name, defaultValue = null) { const found = this.configParameters.find((param) => param.Name?.endsWith(name)); if (!found) { return defaultValue; } return found.Value; } getBool(name, defaultValue = null) { const found = this.configParameters.find((param) => param.Name?.endsWith(name)); if (!found) { return defaultValue; } const isTrue = ConfigParametersService_1.trutyValues.includes(found.Value ?? ''); return isTrue; } getNumber(name, defaultValue = null) { const found = this.configParameters.find((param) => param.Name?.endsWith(name)); if (!found?.Value) { return defaultValue; } return +found.Value; } }; exports.ConfigParametersService = ConfigParametersService; exports.ConfigParametersService = ConfigParametersService = ConfigParametersService_1 = __decorate([ (0, common_1.Injectable)(), __param(0, (0, common_1.Inject)(constants_1.CONFIG_PARAMETERS)), __metadata("design:paramtypes", [Array]) ], ConfigParametersService);