@helix/shared/utils
Shared utility functions for the Helix platform.
Overview
Common utilities for:
- Date/time operations
- Encryption and hashing (AES-256-GCM, bcrypt)
- UUID generation and validation
- String manipulation
- Error handling
- Retry logic with backoff
- Circuit breaker pattern
Installation
import {
getCurrentTimestamp,
encrypt,
decrypt,
generateUuid,
slugify,
retry,
CircuitBreaker,
} from '@helix/shared/utils';
Usage Examples
Date Utilities
const now = getCurrentTimestamp(); // ISO 8601
const tomorrow = addDays(new Date(), 1);
const expired = isExpired(expiryDate);
Encryption
const encrypted = encrypt('sensitive data', process.env.ENCRYPTION_KEY);
const decrypted = decrypt(encrypted, process.env.ENCRYPTION_KEY);
const hashed = await hash('password');
const valid = await compareHash('password', hashed);
Retry Logic
const result = await retry(
() => externalApi.call(),
{ maxAttempts: 3, delayMs: 1000, backoff: 'exponential' }
);
Circuit Breaker
const breaker = new CircuitBreaker({
failureThreshold: 5,
resetTimeout: 60000
});
const result = await breaker.execute(() => externalService.call());
License
Proprietary - CleverChain Limited