nest-vault

Hashicorp Vault wrapper for NestJS

Usage no npm install needed!

<script type="module">
  import nestVault from 'https://cdn.skypack.dev/nest-vault';
</script>

README

Nest-Vault – NestJS wrapper for Hashicorp Vault

This dynamic module was generated with Nest Dynamic Package Generator Schematics. You can read more about using the generator here.

Installation

To install this generated project:

npm install nest-vault --save

(or yarn equivalent)

Test

You can test this module if Hashicorp Vault is running locally at http://127.0.0.1:8200/v1 (or you can edit the .env file to change this URL).

cd ./node_modules/nest-vault
npm run start:dev

Then connect to http://localhost:3000 and you should see the status of your vault.

Usage

@Module({
  imports: [
    ConfigModule.forRoot({}),

    NestVaultModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => {
        return {
          baseUrl: configService.get('VAULT_URL'),
        };
      },
    }),
  ],
})

Look at src/nest-vault-client for more details.

This wrapper is using hashi-vault-js module, so take a look how to use it.

@Controller()
export class NestVaultClientController {
  constructor(@Inject(VAULT_CONNECTION) private readonly vault) {}

  @Get()
  async index() {
    return await this.vault.healthCheck();
  }
}

Good luck!