import { Injectable, Inject } from '@nestjs/common'; import { VAULT_OPTIONS } from './constants'; import { NestVaultOptions } from './interfaces'; // tslint:disable-next-line:no-var-requires const Vault = require('hashi-vault-js'); /** * Sample interface for NestVaultService * * Customize this as needed to describe the NestVaultService * */ interface INestVaultService { getVault(); } @Injectable() export class NestVaultService implements INestVaultService { private vaultConnection: any; constructor(@Inject(VAULT_OPTIONS) private nestVaultOptions: NestVaultOptions) {} getVault(): any { if (!this.vaultConnection) { this.vaultConnection = new Vault(this.nestVaultOptions); } return this.vaultConnection; } }