@avishaidotan/shared-lib
v1.1.0
Published
Shared library for Cymulate project
Readme
Shared Library
A shared TypeScript library providing common types, services, and helpers for microservices.
Features
- Zod schemas and type definitions
- AES Encryption Service
- Database Service
- Environment variables management
Installation
npm install github:your-username/shared-libUsage
- Create a
.envfile in your project root:
ENCRYPTION_KEY=your-secret-key
DB_CONNECTION_STRING=your-database-connection-string- Import and use the services:
import { EncryptionService, DbService, User, UserSchema } from 'shared-lib';
// Using the Encryption Service
const encryptionService = new EncryptionService();
const encrypted = encryptionService.encrypt('sensitive data');
const decrypted = encryptionService.decrypt(encrypted);
// Using the DB Service
const dbService = new DbService();
await dbService.connect();
// Using Types and Schemas
const userData = {
id: '123',
email: '[email protected]',
name: 'John Doe'
};
const validatedUser = UserSchema.parse(userData);
const user: User = validatedUser;Environment Variables
The following environment variables are required:
ENCRYPTION_KEY: Secret key for AES encryptionDB_CONNECTION_STRING: Database connection string
Development
- Clone the repository
- Install dependencies:
npm install - Build the project:
npm run build# shared