Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ab-testing/analysis/statistical-analysis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class StatisticalAnalysisService {
*/
private getZScore(confidenceLevel: number): number {
const confidence = confidenceLevel / 100;
const alpha = 1 - confidence;
const _alpha = 1 - confidence;

// Z-scores for common confidence levels
const zScores: Record<number, number> = {
Expand Down
3 changes: 2 additions & 1 deletion src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AuthController } from './auth.controller';
import { UsersModule } from '../users/users.module';
import { JwtStrategy } from './strategies/jwt.strategy';
import { SessionModule } from '../session/session.module';
import { TransactionService } from '../common/database/transaction.service';

@Module({
imports: [
Expand All @@ -28,7 +29,7 @@ import { SessionModule } from '../session/session.module';
}),
],
controllers: [AuthController],
providers: [AuthService, JwtStrategy],
providers: [AuthService, JwtStrategy, TransactionService],
exports: [AuthService],
})
export class AuthModule {}
76 changes: 40 additions & 36 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RegisterDto, LoginDto, ResetPasswordDto, ChangePasswordDto } from './dt
import * as bcrypt from 'bcryptjs';
import { randomBytes } from 'crypto';
import { SessionService } from '../session/session.service';
import { TransactionService } from '../common/database/transaction.service';

@Injectable()
export class AuthService {
Expand All @@ -14,45 +15,48 @@ export class AuthService {
private readonly jwtService: JwtService,
private readonly configService: ConfigService,
private readonly sessionService: SessionService,
private readonly transactionService: TransactionService,
) {}

async register(registerDto: RegisterDto) {
// Create user
const user = await this.usersService.create(registerDto);

// Generate email verification token
const verificationToken = this.generateRandomToken();
const verificationExpires = new Date(Date.now() + 24 * 60 * 60 * 1000); // 24 hours

await this.usersService.updateEmailVerificationToken(
user.id,
verificationToken,
verificationExpires,
);

// TODO: Send verification email
// await this.emailService.sendVerificationEmail(user.email, verificationToken);

const sessionId = await this.sessionService.createSession(user.id, { type: 'auth-register' });
const { accessToken, refreshToken } = await this.generateTokens(user, sessionId);

// Save refresh token
const hashedRefreshToken = await bcrypt.hash(refreshToken, 10);
await this.usersService.updateRefreshToken(user.id, hashedRefreshToken);

return {
user: {
id: user.id,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
role: user.role,
isEmailVerified: user.isEmailVerified,
},
accessToken,
refreshToken,
message: 'Registration successful. Please check your email to verify your account.',
};
return await this.transactionService.runInTransaction(async (_manager) => {
// Create user
const user = await this.usersService.create(registerDto);

// Generate email verification token
const verificationToken = this.generateRandomToken();
const verificationExpires = new Date(Date.now() + 24 * 60 * 60 * 1000); // 24 hours

await this.usersService.updateEmailVerificationToken(
user.id,
verificationToken,
verificationExpires,
);

// TODO: Send verification email
// await this.emailService.sendVerificationEmail(user.email, verificationToken);

const sessionId = await this.sessionService.createSession(user.id, { type: 'auth-register' });
const { accessToken, refreshToken } = await this.generateTokens(user, sessionId);

// Save refresh token
const hashedRefreshToken = await bcrypt.hash(refreshToken, 10);
await this.usersService.updateRefreshToken(user.id, hashedRefreshToken);

return {
user: {
id: user.id,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
role: user.role,
isEmailVerified: user.isEmailVerified,
},
accessToken,
refreshToken,
message: 'Registration successful. Please check your email to verify your account.',
};
});
}

async login(loginDto: LoginDto) {
Expand Down
2 changes: 1 addition & 1 deletion src/backup/processing/backup-queue.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class BackupQueueProcessor {
}

@Process('recovery-test')
async handleRecoveryTest(job: Job<RecoveryTestJobData>) {
async handleRecoveryTest(_job: Job<RecoveryTestJobData>) {
this.logger.log(`Recovery test processing handled by RecoveryTestingService`);
// Delegated to RecoveryTestingService.executeRecoveryTest()
}
Expand Down
8 changes: 4 additions & 4 deletions src/cdn/caching/edge-caching.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class EdgeCachingService {
}
}

async getCacheStatus(url: string): Promise<{
async getCacheStatus(_url: string): Promise<{
cached: boolean;
age?: number;
expires?: Date;
Expand Down Expand Up @@ -140,17 +140,17 @@ export class EdgeCachingService {
];
}

private async getUrlsByTags(tags: string[]): Promise<string[]> {
private async getUrlsByTags(_tags: string[]): Promise<string[]> {
// Implementation would query database for URLs with specific tags
return [];
}

private async getUrlsByPattern(pattern: string): Promise<string[]> {
private async getUrlsByPattern(_pattern: string): Promise<string[]> {
// Implementation would find URLs matching pattern
return [];
}

private async prefetchToEdge(url: string): Promise<void> {
private async prefetchToEdge(_url: string): Promise<void> {
// Implementation would make requests to warm the cache
// This might involve calling CDN APIs or making HTTP requests
}
Expand Down
4 changes: 2 additions & 2 deletions src/cdn/cdn.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class CdnController {
providers,
timestamp: new Date().toISOString(),
};
} catch (error) {
} catch (_error) {
console.error('health check failed');
throw new HttpException('Health check failed', HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ export class CdnController {
end: end.toISOString(),
},
};
} catch (error) {
} catch (_error) {
console.error('failed to retrieve');
throw new HttpException('Failed to retrieve analytics', HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand Down
4 changes: 2 additions & 2 deletions src/cdn/cdn.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class CdnService {
metadata.status = ContentStatus.PROCESSING;
await this.contentMetadataRepository.save(metadata);

const optimizedUrl = await this.assetOptimizationService.optimizeImage(
const _optimizedUrl = await this.assetOptimizationService.optimizeImage(
metadata.cdnUrl,
options,
);
Expand Down Expand Up @@ -219,7 +219,7 @@ export class CdnService {
}
}

private async optimizeForBandwidth(url: string, bandwidth: number): Promise<string> {
private async optimizeForBandwidth(url: string, _bandwidth: number): Promise<string> {
// Implementation would adjust quality/format based on bandwidth
// For now, return original URL
return url;
Expand Down
2 changes: 1 addition & 1 deletion src/cdn/geo/geo-location.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class GeoLocationService {
return degrees * (Math.PI / 180);
}

private mockGeolocation(ipAddress: string): LocationInfo {
private mockGeolocation(_ipAddress: string): LocationInfo {
// Mock implementation - in real app, use actual geolocation service
return {
country: 'US',
Expand Down
42 changes: 21 additions & 21 deletions src/cdn/optimization/asset-optimization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,60 @@ export interface OptimizationResult {

@Injectable()
export class AssetOptimizationService {
async optimizeImage(imageUrl: string, options: ContentDeliveryOptions): Promise<string> {
async optimizeImage(contentId: string, _options: any): Promise<string> {
try {
// Download image (in real implementation, you'd fetch from storage)
// For now, assume we have the buffer
const buffer = await this.downloadImage(imageUrl);
const buffer = await this.downloadImage(contentId);

let sharpInstance = sharp(buffer);

// Apply optimizations
if (options.width || options.height) {
if (_options.width || _options.height) {
sharpInstance = sharpInstance.resize({
width: options.width,
height: options.height,
width: _options.width,
height: _options.height,
fit: 'cover',
withoutEnlargement: true,
});
}

if (options.quality) {
sharpInstance = sharpInstance.jpeg({ quality: options.quality });
if (_options.quality) {
sharpInstance = sharpInstance.jpeg({ quality: _options.quality });
}

if (options.format) {
switch (options.format) {
if (_options.format) {
switch (_options.format) {
case 'webp':
sharpInstance = sharpInstance.webp({ quality: options.quality || 80 });
sharpInstance = sharpInstance.webp({ quality: _options.quality || 80 });
break;
case 'png':
sharpInstance = sharpInstance.png({ quality: options.quality || 80 });
sharpInstance = sharpInstance.png({ quality: _options.quality || 80 });
break;
case 'jpeg':
default:
sharpInstance = sharpInstance.jpeg({ quality: options.quality || 80 });
sharpInstance = sharpInstance.jpeg({ quality: _options.quality || 80 });
break;
}
}

const optimizedBuffer = await sharpInstance.toBuffer();
const optimizedUrl = await this.uploadOptimizedImage(optimizedBuffer, imageUrl, options);
const optimizedUrl = await this.uploadOptimizedImage(optimizedBuffer, contentId, _options);

return optimizedUrl;
} catch (error) {
console.error('Image optimization failed:', error);
return imageUrl; // Return original if optimization fails
return contentId; // Return original if optimization fails
}
}

async optimizeVideo(videoUrl: string, options: ContentDeliveryOptions): Promise<string> {
async optimizeVideo(contentId: string, _options: any): Promise<string> {
// Implementation for video optimization using ffmpeg
// For now, return original
return videoUrl;
return contentId;
}

async generateResponsiveImages(imageUrl: string): Promise<OptimizationResult[]> {
async generateResponsiveImages(contentId: string): Promise<OptimizationResult[]> {
const results: OptimizationResult[] = [];
const sizes = [
{ width: 320, suffix: 'sm' },
Expand All @@ -73,15 +73,15 @@ export class AssetOptimizationService {
{ width: 1920, suffix: 'xl' },
];

const buffer = await this.downloadImage(imageUrl);
const buffer = await this.downloadImage(contentId);

for (const size of sizes) {
const optimized = await sharp(buffer)
.resize(size.width, null, { withoutEnlargement: true })
.webp({ quality: 80 })
.toBuffer();

const url = await this.uploadOptimizedImage(optimized, imageUrl, {
const url = await this.uploadOptimizedImage(optimized, contentId, {
width: size.width,
format: 'webp',
});
Expand All @@ -97,7 +97,7 @@ export class AssetOptimizationService {
return results;
}

private async downloadImage(url: string): Promise<Buffer> {
private async downloadImage(_url: string): Promise<Buffer> {
// In real implementation, download from storage/CDN
// For now, return empty buffer
throw new Error('Download implementation needed');
Expand All @@ -123,7 +123,7 @@ export class AssetOptimizationService {
return parts.join('_');
}

async getOptimizationStats(contentId: string): Promise<{
async getOptimizationStats(_contentId: string): Promise<{
originalSize: number;
optimizedSize: number;
savingsPercentage: number;
Expand Down
8 changes: 3 additions & 5 deletions src/cdn/providers/aws-cloudfront.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class AWSCloudFrontService {
}
}

async getDistributionMetrics(startDate: Date, endDate: Date): Promise<any> {
async getUsageStatistics(_startDate: Date, _endDate: Date): Promise<any> {
// AWS CloudFront doesn't have direct metrics API in SDK
// Would need to use CloudWatch or external monitoring
// For now, return mock data
Expand All @@ -201,16 +201,14 @@ export class AWSCloudFrontService {
};
}

async updateDistributionSettings(settings: any): Promise<boolean> {
async updateDistributionSettings(_settings: any): Promise<void> {
try {
// Get current distribution config
// This would require additional API calls to get and update distribution
// For now, return success
this.logger.log('Updating CloudFront distribution settings');
return true;
} catch (error) {
this.logger.error('Failed to update distribution settings:', error);
return false;
}
}

Expand Down Expand Up @@ -274,7 +272,7 @@ export class AWSCloudFrontService {
}
}

async getFileMetadata(key: string): Promise<any> {
async getFileMetadata(_key: string): Promise<any> {
// Implementation would get object metadata from S3
return {
size: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/collaboration/gateway/collaboration.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export class CollaborationGateway
private readonly permissionsService: CollaborationPermissionsService,
) {}

afterInit(server: Server) {
afterInit(_server: Server) {
this.logger.log('Collaboration Gateway initialized');
}

async handleConnection(@ConnectedSocket() client: Socket) {
async handleConnection(_server: any, @ConnectedSocket() client: Socket) {
this.logger.log(`Client connected: ${client.id}`);

// Optionally authenticate the user here based on token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class CollaborationPermissionsService {
`Granted ${permission} permission to user ${userId} for resource ${resourceId}`,
);

return this.getUserPermission(resourceId, userId)!;
return this.getUserPermission(resourceId, userId) ?? null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/collaboration/versioning/version-control.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class VersionControlService {
changesByUser.set(version.userId, userCount + 1);

// Group by day for time series
const dateStr = new Date(version.timestamp).toDateString();
const _dateStr = new Date(version.timestamp).toDateString();
const timeEntry = changesOverTime.find(
(entry) => entry.date.toDateString() === new Date(version.timestamp).toDateString(),
);
Expand Down Expand Up @@ -220,7 +220,7 @@ export class VersionControlService {
/**
* Extract the previous value from history
*/
private getPreviousValue(history: VersionHistory, change: any): any {
private getPreviousValue(history: VersionHistory, _change: any): any {
// In a real implementation, this would retrieve the previous state
// For now, we'll return the last recorded value if available
if (history.versions.length > 0) {
Expand Down
Loading
Loading