@ai-workflow-pack/common
v1.0.1
Published
Shared common utilities, decorators, guards, and interceptors for AI Workflow services
Maintainers
Readme
@ai-workflow-pack/common
Shared common utilities, decorators, guards, interceptors, and filters for AI Workflow microservices.
Installation
npm install @ai-workflow-pack/commonUsage
Decorators
import { CurrentUser, TenantId, Roles } from '@ai-workflow-pack/common';
@Controller('users')
export class UsersController {
@Get('me')
@Roles('user', 'admin')
getProfile(
@CurrentUser() user: User,
@TenantId() tenantId: number
) {
return user;
}
}Guards
import { JwtAuthGuard, RolesGuard, TenantGuard } from '@ai-workflow-pack/common';
@Controller('workflows')
@UseGuards(JwtAuthGuard, TenantGuard, RolesGuard)
export class WorkflowsController {
// Protected routes
}Interceptors
import { LoggingInterceptor, TransformInterceptor } from '@ai-workflow-pack/common';
@UseInterceptors(LoggingInterceptor, TransformInterceptor)
@Controller('api')
export class ApiController {}Utilities
import { CryptoUtil, DateUtil, ValidationUtil } from '@ai-workflow-pack/common';
// Encrypt/decrypt sensitive data
const encrypted = CryptoUtil.encrypt('secret-data');
const decrypted = CryptoUtil.decrypt(encrypted);
// Date formatting
const formatted = DateUtil.format(new Date(), 'YYYY-MM-DD');
// Validation
const isValid = ValidationUtil.isEmail('[email protected]');Features
- 🔐 Authentication Decorators:
@CurrentUser(),@TenantId(),@ApiKey() - 🛡️ Guards: JWT, Roles, Tenant isolation, API Key validation
- 🔍 Interceptors: Logging, Response transformation, Timeout handling
- 🚫 Filters: HTTP exceptions, Global error handling
- 🔧 Utilities: Crypto, Date, String manipulation, Validation
- 📝 Constants: Roles, Status codes, Error messages
License
MIT
