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
15 changes: 14 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ QUEUE_REMOVE_ON_FAIL=false
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES_IN=3600
JWT_REFRESH_SECRET=your-refresh-secret-key-change-this-in-production

# Email (SMTP) Configuration - Nodemailer
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=noreply@swaptrade.com
SMTP_PASSWORD=your-smtp-password
EMAIL_FROM=noreply@swaptrade.com

# SMS Configuration - Twilio
TWILIO_ACCOUNT_SID=your-twilio-account-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
TWILIO_PHONE_NUMBER=+1234567890
JWT_REFRESH_EXPIRES_IN=604800
BCRYPT_ROUNDS=12
AUTH_MAX_LOGIN_ATTEMPTS=5
Expand Down Expand Up @@ -119,4 +132,4 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318/v1/traces
# Sampling rate: 1.0 = 100 % of traces, 0.1 = 10 %, etc.
OTEL_SAMPLING_RATE=1.0
# How often (ms) the batch processor flushes spans in production
OTEL_EXPORT_INTERVAL=5000
OTEL_EXPORT_INTERVAL=5000
3,159 changes: 3,109 additions & 50 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { PoolSwap } from './exchange/entities/pool-swap.entity';
import { EmergencyWithdrawal } from './exchange/entities/emergency-withdrawal.entity';
import { ExchangeModule } from './exchange/exchange.module';
import { MobileModule } from './mobile/mobile.module';
import { NotificationsModule } from './notifications/notifications.module';

@Module({
imports: [
Expand All @@ -81,7 +82,7 @@ import { MobileModule } from './mobile/mobile.module';
I18nModule.forRoot({
fallbackLanguage: 'en',
loaderOptions: {
path: path.join(__dirname, '/i18n/'),
path: path.join(__dirname, '/notifications/templates/i18n/'),
watch: true,
},
resolvers: [
Expand All @@ -103,7 +104,7 @@ import { MobileModule } from './mobile/mobile.module';
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
type: configService.get<string>('DB_TYPE', 'postgres') as '' | 'sqlite',
type: configService.get<string>('DB_TYPE', 'postgres') as 'postgres' | 'sqlite',
host: configService.get<string>('DB_HOST', 'localhost'),
port: configService.get<number>('DB_PORT', 5432),
username: configService.get<string>('DB_USERNAME', 'postgres'),
Expand Down Expand Up @@ -169,17 +170,20 @@ import { MobileModule } from './mobile/mobile.module';
// ── Trading Features — Advanced Order Types (issue #382) ──
OrdersModule,

// ── Mobile Integration ──
// Mobile Integration ──
MobileModule,
// ── Institutional Portal ──
InstitutionalModule,
// ── AI Features — Trading Assistant (issue #395) ──
AiTradingAssistantModule,

// ── Notifications Module ──
NotificationsModule,

// ── Error Handling ──
ErrorModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
export class AppModule {}
7 changes: 4 additions & 3 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { Request } from 'express';
import type { Request } from 'express';

import { AuthService } from './auth.service';
import { RegisterDto } from './dto/register.dto';
Expand All @@ -29,7 +29,8 @@ import {
ChangePasswordDto,
} from './dto/password-reset.dto';
import { Enable2FADto, TwoFADto, Verify2FASetupDto } from './dto/2fa.dto';
import { JwtAuthGuard, JwtPayload } from './guards/jwt-auth.guard';
import { JwtAuthGuard } from './guards/jwt-auth.guard';
import type { JwtPayload } from './guards/jwt-auth.guard';
import { CurrentUser } from './decorators/current-user.decorator';
import { Public } from './decorators/public.decorator';
import { ApiAuthErrorResponses } from '../common/decorators/swagger-error-responses.decorator';
Expand Down Expand Up @@ -201,4 +202,4 @@ export class AuthController {
disable2FA(@CurrentUser() user: JwtPayload, @Body() dto: TwoFADto) {
return this.authService.disable2FA(user.sub, dto);
}
}
}
4 changes: 2 additions & 2 deletions src/auth/mfa.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagg
import { MFAService } from './mfa.service';
import { JwtAuthGuard } from './guards/jwt-auth.guard';
import { CurrentUser } from './decorators/current-user.decorator';
import { JwtPayload } from './guards/jwt-auth.guard';
import type { JwtPayload } from './guards/jwt-auth.guard';

@ApiTags('identity/auth/mfa')
@UseGuards(JwtAuthGuard)
Expand Down Expand Up @@ -53,4 +53,4 @@ export class MFAController {
const isValid = await this.mfaService.verifyToken(user.sub, body.token);
return { success: isValid };
}
}
}
5 changes: 5 additions & 0 deletions src/common/enums/notification-channel.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum NotificationChannel {
EMAIL = 'EMAIL',
SMS = 'SMS',
PUSH = 'PUSH',
}
7 changes: 6 additions & 1 deletion src/common/enums/notification-event-type.enum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export enum NotificationEventType {
ORDER_FILLED = 'ORDER_FILLED',
TRADE_EXECUTED = 'TRADE_EXECUTED',
LIQUIDATION = 'LIQUIDATION',
DEPOSIT_RECEIVED = 'DEPOSIT_RECEIVED',
PRICE_ALERT = 'PRICE_ALERT',
ACHIEVEMENT_UNLOCKED = 'ACHIEVEMENT_UNLOCKED',
}
WITHDRAWAL_COMPLETED = 'WITHDRAWAL_COMPLETED',
SECURITY_ALERT = 'SECURITY_ALERT',
}
7 changes: 6 additions & 1 deletion src/common/enums/notification-status.enum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export enum NotificationStatus {
PENDING = 'PENDING',
PROCESSING = 'PROCESSING',
RETRYING = 'RETRYING',
SENT = 'SENT',
DELIVERED = 'DELIVERED',
READ = 'READ',
FAILED = 'FAILED',
}
PERMANENTLY_FAILED = 'PERMANENTLY_FAILED',
}
4 changes: 2 additions & 2 deletions src/common/logging/audit_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface UserAuditData {
}

interface CreateEntryDto {
userId: number;
userId: string;
eventType: string;
entityType: string;
entityId: string;
Expand Down Expand Up @@ -278,4 +278,4 @@ export class AuditService {

this.logger.audit(auditData);
}
}
}
4 changes: 1 addition & 3 deletions src/common/monitoring/interceptors/monitoring.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ export class MonitoringInterceptor implements NestInterceptor {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;

context.active(); // keep TypeScript happy — using OTel context below

// Bind the handler execution to the active span context
const handlerResult$ = (
require('@opentelemetry/api').context as typeof import('@opentelemetry/api').context
Expand Down Expand Up @@ -211,4 +209,4 @@ export class MonitoringInterceptor implements NestInterceptor {
.subscribe(subscriber);
});
}
}
}
2 changes: 1 addition & 1 deletion src/governance/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './constants/governance.constants';
export * from './governance.constants';
1 change: 1 addition & 0 deletions src/governance/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './governance.controller';
8 changes: 7 additions & 1 deletion src/governance/entities/governance-proposal.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,10 @@ export class GovernanceProposal {

@UpdateDateColumn()
updatedAt: Date;
}

@Column('decimal', { precision: 18, scale: 8, default: 51 })
passThresholdVotes: number;

@Column({ nullable: true })
executionReason: string;
}
9 changes: 8 additions & 1 deletion src/governance/entities/governance-vote.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
} from 'typeorm';

Expand Down Expand Up @@ -40,4 +41,10 @@ export class GovernanceVote {

@Column('text', { nullable: true })
reason: string;
}

@CreateDateColumn()
createdAt: Date;

@UpdateDateColumn()
updatedAt: Date;
}
7 changes: 7 additions & 0 deletions src/governance/entities/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './governance-config.entity';
export * from './governance-discussion.entity';
export * from './governance-execution.entity';
export * from './governance-proposal.entity';
export * from './governance-vote.entity';
export * from './token-holding.entity';
export * from './vote-delegation.entity';
6 changes: 3 additions & 3 deletions src/governance/services/governance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
ProposalType,
VoteType,
DiscussionMessageType,
GOVERNANCE_PARAMS,
} from '../constants/governance.constants';
} from '../enums/governance.enum';
import { GOVERNANCE_PARAMS } from '../constants/governance.constants';
import {
GovernanceProposal,
GovernanceVote,
Expand Down Expand Up @@ -176,4 +176,4 @@ export class GovernanceService {
take: limit,
});
}
}
}
Loading
Loading