Class VaultConnector

Description

Vault connector

Features:

  • connector manager for vault

Example

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { VaultConnector } from '@biorate/vault';

export class Root extends Core() {
@inject(VaultConnector) public connector: VaultConnector;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<VaultConnector>(VaultConnector).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

container.get<IConfig>(Types.Config).merge({
Vault: [
{
name: 'connection',
options: {
apiVersion: 'v1',
endpoint: 'http://localhost:8200',
token: 'admin',
},
},
],
});

(async () => {
const root = container.get<Root>(Root);
await root.$run();
await root.connector.current!.write('secret/data/test.json', {
data: { hello: 'world' },
});
const result = await root.connector.current!.read('secret/data/test.json');
console.log(result.data.data); // { hello: 'world' }
})();

Hierarchy

Constructors

Properties

#connections: Map<string, client>

Description

Private connections storage

#connections: Map<string, client> = ...

Description

Private connections storage

#current: client

Description

Private link to selected (used) connection

#current: client = undefined

Description

Private link to selected (used) connection

config: IConfig

Description

Config dependency

namespace: "Vault" = 'Vault'

Description

Namespace path for fetching configuration

Accessors

Methods

Generated using TypeDoc