< Summary - Envilder Core (TypeScript)

Information
Class: src/envilder/core/application/pushSingle/PushSingleCommandHandler.ts
Assembly: Default
File(s): src/envilder/core/application/pushSingle/PushSingleCommandHandler.ts
Tag: 151_24479375065
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 46
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/envilder/core/application/pushSingle/PushSingleCommandHandler.ts

#LineLine coverage
 1import { inject, injectable } from 'inversify';
 2import { EnvironmentVariable } from '../../domain/EnvironmentVariable.js';
 3import type { ILogger } from '../../domain/ports/ILogger.js';
 4import type { ISecretProvider } from '../../domain/ports/ISecretProvider.js';
 5import { TYPES } from '../../types.js';
 6import type { PushSingleCommand } from './PushSingleCommand.js';
 7
 8@injectable()
 89export class PushSingleCommandHandler {
 10  constructor(
 11    @inject(TYPES.ISecretProvider)
 2112    private readonly secretProvider: ISecretProvider,
 2113    @inject(TYPES.ILogger) private readonly logger: ILogger,
 14  ) {}
 15
 16  /**
 17   * Handles the PushSingleCommand which pushes a single environment variable to the secret store.
 18   *
 19   * @param command - The PushSingleCommand containing key, value and secretPath
 20   */
 21  async handle(command: PushSingleCommand): Promise<void> {
 322    try {
 323      this.logger.info(
 24        `Starting push operation for key '${command.key}' to path '${EnvironmentVariable.maskSecretPath(command.secretPa
 25      );
 26
 327      const envVariable = new EnvironmentVariable(
 28        command.key,
 29        command.value,
 30        true,
 31      );
 32
 333      await this.secretProvider.setSecret(command.secretPath, command.value);
 234      this.logger.info(
 35        `Pushed ${command.key}=${envVariable.maskedValue} to secret store at path ${EnvironmentVariable.maskSecretPath(c
 36      );
 37    } catch (error) {
 38      const errorMessage =
 139        error instanceof Error ? error.message : String(error);
 140      this.logger.error(
 41        `Failed to push variable to secret store: ${errorMessage}`,
 42      );
 143      throw error;
 44    }
 45  }
 46}

Methods/Properties

(anonymous_0)
(anonymous_1)