A NestJS microservice for generating and downloading enterprise-grade cryptographic SDKs for multiple programming languages.
This microservice handles:
- SDK Generation: Generate SDKs for 13+ programming languages
- SDK Download: Create and stream ZIP archives of generated SDKs
- Code Reusability: Modular architecture with separated concerns
┌─────────────────────────────────────────┐
│ SDK Controller │
│ (REST API Endpoints) │
└──────────────┬──────────────────────────┘
│
┌───────┴────────┐
│ │
┌──────▼──────┐ ┌──────▼────────┐
│ Generation │ │ Download │
│ Service │ │ Service │
└──────┬──────┘ └──────┬────────┘
│ │
└────────┬────────┘
│
┌───────▼──────────┐
│ Enterprise │
│ Adapter Service │
└───────┬──────────┘
│
┌───────▼──────────┐
│ SDK Generator │
│ (CommonJS) │
└──────────────────┘
- ✅ Multi-language Support: JavaScript, Python, Java, Go, C/C++, C#, Swift, Kotlin, Rust, PHP, Ruby, Scala, Dart
- ✅ Enterprise Security: All 18 security gates implemented
- ✅ ZIP Archive Generation: Automatic packaging of SDK files
- ✅ Validation: Request validation with class-validator
- ✅ Error Handling: Comprehensive error handling and logging
- ✅ Modular Design: Separated services for generation and download
Generate SDKs for specified languages.
Request Body:
{
"sdkId": "sdk-123",
"name": "MySDK",
"version": "2.0.0",
"languages": ["javascript", "python"],
"algorithms": ["aes-256-gcm"],
"tenantId": "tenant-123",
"telemetryEnabled": true,
"envelopeEncryptionEnabled": true
}Response:
{
"success": true,
"data": {
"success": true,
"sdkId": "sdk-123",
"languages": ["javascript", "python"],
"fileCounts": {
"javascript": 15,
"python": 12
},
"message": "SDK generation completed successfully"
}
}Generate and download SDK as ZIP archive.
Request Body: (Same as generate endpoint)
Response: ZIP file stream with appropriate headers
Get estimated archive size before download.
Request Body: (Same as generate endpoint)
Response:
{
"success": true,
"size": 1024000,
"sizeFormatted": "1 MB"
}Health check endpoint.
Response:
{
"status": "ok",
"service": "sdk-generation",
"timestamp": "2024-01-01T00:00:00.000Z"
}cd services/sdk
npm install# Development
npm run start:dev
# Production
npm run build
npm run start:prodPORT=33201
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com- @nestjs/common: NestJS core framework
- archiver: ZIP archive creation
- class-validator: Request validation
- class-transformer: Data transformation
src/
├── main.ts # Application entry point
├── app.module.ts # Root module
└── sdk/
├── sdk.controller.ts # REST API endpoints
├── sdk.module.ts # SDK module
├── sdk.service.ts # Base SDK service
├── dto/
│ ├── create-sdk.dto.ts # Create SDK DTO
│ ├── generate-sdk.dto.ts # Generate SDK DTO
│ └── update-sdk.dto.ts # Update SDK DTO
├── entities/
│ └── sdk.entity.ts # SDK entity
├── interfaces/
│ └── sdk-generator.interface.ts # TypeScript interfaces
└── services/
├── enterprise-adapter.service.ts # Generator adapter
├── sdk-generation.service.ts # Generation logic
└── sdk-download.service.ts # Download logic
The main application can call this microservice via HTTP:
// Example: Call from main application
const response = await fetch('http://localhost:33201/sdk/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
sdkId: sdk.id,
name: sdk.name,
version: sdk.version,
languages: sdk.languages,
algorithms: sdk.algorithms,
// ... other fields
}),
});The service automatically resolves the SDK generator path by checking:
../../generators/main-generator.cjs(modular structure)../enterprise-sdk-generator-fixed.cjs(original structure)- Current working directory paths
Ensure the generator files are accessible from the microservice location.
All endpoints include comprehensive error handling:
- Validation errors return 400 Bad Request
- Generation errors return 500 Internal Server Error
- All errors are logged with context
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Coverage
npm run test:covUNLICENSED