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 jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
rootDir: '.',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
'^.+\\.(t|j)s$': ['ts-jest', { diagnostics: false }],
},
collectCoverageFrom: [
'src/**/*.(t|j)s',
Expand Down
108 changes: 104 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ enum MilestoneStatus {
DELAYED
}

enum DisputeStatus {
OPEN
UNDER_REVIEW
RESOLVED
CANCELLED
}

// User model
model User {
Expand Down Expand Up @@ -204,6 +198,7 @@ model User {
blacklistedTokens BlacklistedToken[]
preferences UserPreferences?
activityLogs ActivityLog[]
documentVersions DocumentVersion[] @relation("DocumentVersionUploader")
verificationDocuments VerificationDocument[]
sessions Session[]
passwordResetTokens PasswordResetToken[]
Expand Down Expand Up @@ -450,6 +445,7 @@ model Transaction {
disputes Dispute[]
transactionMilestones TransactionMilestone[]
transactionHistory TransactionHistory[]
cancelledBy User? @relation("CancelledTransactions", fields: [cancelledById], references: [id])

@@index([propertyId])
@@index([buyerId])
Expand Down Expand Up @@ -514,6 +510,7 @@ model Document {
// Relations
property Property? @relation(fields: [propertyId], references: [id], onDelete: SetNull)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
versions DocumentVersion[]
dispute Dispute? @relation(fields: [disputeId], references: [id], onDelete: SetNull)

@@index([propertyId])
Expand Down
13 changes: 12 additions & 1 deletion src/admin/admin.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { Body, Controller, Get, Param, Patch, Post, Put, Query, Res, UseGuards } from '@nestjs/common';
import {
Body,
Controller,
Get,
Param,
Patch,
Post,
Put,
Query,
Res,
UseGuards,
} from '@nestjs/common';
import { Response } from 'express';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { Roles } from '../auth/decorators/roles.decorator';
Expand Down
22 changes: 11 additions & 11 deletions src/admin/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ export class AdminService {

const [completedTransactions, pendingTransactions, salesAggregate, rentAggregate] =
await Promise.all([
this.prisma.transaction.count({ where: { status: TransactionStatus.COMPLETED } }),
this.prisma.transaction.count({ where: { status: TransactionStatus.PENDING } }),
this.prisma.transaction.aggregate({
where: { status: TransactionStatus.COMPLETED, type: TransactionType.SALE },
_sum: { amount: true },
}),
this.prisma.transaction.aggregate({
where: { status: TransactionStatus.COMPLETED, type: TransactionType.TRANSFER },
_sum: { amount: true },
}),
]);
this.prisma.transaction.count({ where: { status: TransactionStatus.COMPLETED } }),
this.prisma.transaction.count({ where: { status: TransactionStatus.PENDING } }),
this.prisma.transaction.aggregate({
where: { status: TransactionStatus.COMPLETED, type: TransactionType.SALE },
_sum: { amount: true },
}),
this.prisma.transaction.aggregate({
where: { status: TransactionStatus.COMPLETED, type: TransactionType.TRANSFER },
_sum: { amount: true },
}),
]);

return {
userStats: {
Expand Down
11 changes: 4 additions & 7 deletions src/backup/backup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import {
OnModuleInit,
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import {
BackupStatus,
BackupTrigger,
DatabaseBackup,
RestoreStatus,
} from '@prisma/client';
import { BackupStatus, BackupTrigger, DatabaseBackup, RestoreStatus } from '@prisma/client';
import { CronJob } from 'cron';
import * as crypto from 'crypto';
import * as fs from 'fs';
Expand Down Expand Up @@ -337,7 +332,9 @@ export class BackupService implements OnModuleInit {
}

private getStoragePath() {
return this.configService.get<string>('BACKUP_STORAGE_PATH') ?? path.join(process.cwd(), 'backups');
return (
this.configService.get<string>('BACKUP_STORAGE_PATH') ?? path.join(process.cwd(), 'backups')
);
}

private ensureDatabaseUrl() {
Expand Down
4 changes: 1 addition & 3 deletions src/blockchain/blockchain.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ describe('BlockchainService', () => {
it('should reject invalid addresses', () => {
expect(service.isValidAddress('invalid')).toBe(false);
expect(service.isValidAddress('0x123')).toBe(false);
expect(service.isValidAddress('0xGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG')).toBe(
false,
);
expect(service.isValidAddress('0xGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG')).toBe(false);
});
});

Expand Down
13 changes: 8 additions & 5 deletions src/blockchain/blockchain.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export class BlockchainService {
private contract: any;
private transactionCache = new Map<string, BlockchainTransaction>();

constructor(private configService: ConfigService, private prisma: PrismaService) {
constructor(
private configService: ConfigService,
private prisma: PrismaService,
) {
this.initializeConfig();
}

Expand Down Expand Up @@ -336,11 +339,11 @@ export class BlockchainService {
},
});

const confirmed = transactions.filter((t) => t.status === 'COMPLETED');
const pending = transactions.filter((t) => t.status === 'PENDING');
const failed = transactions.filter((t) => t.status === 'FAILED');
const confirmed = transactions.filter((t) => t.status === ('COMPLETED' as any));
const pending = transactions.filter((t) => t.status === ('PENDING' as any));
const failed = transactions.filter((t) => t.status === ('FAILED' as any));

const totalValue = confirmed.reduce((sum, t) => sum + t.amount.toNumber(), 0);
const totalValue = confirmed.reduce((sum: number, t: any) => sum + t.amount.toNumber(), 0);

return {
totalTransactions: transactions.length,
Expand Down
9 changes: 4 additions & 5 deletions src/email-digest/email-digest.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export class EmailDigestController {

@UseGuards(JwtAuthGuard)
@Patch('preference')
updatePreference(
@CurrentUser() user: { id: string },
@Body() dto: UpdateDigestPreferenceDto,
) {
updatePreference(@CurrentUser() user: { id: string }, @Body() dto: UpdateDigestPreferenceDto) {
return this.emailDigestService.updatePreference(user.id, dto);
}

Expand All @@ -30,6 +27,8 @@ export class EmailDigestController {
const message = success
? 'You have been unsubscribed from PropChain email digests.'
: 'Invalid or expired unsubscribe link.';
return res.send(`<html><body style="font-family:Arial;text-align:center;padding:40px"><h2>${message}</h2></body></html>`);
return res.send(
`<html><body style="font-family:Arial;text-align:center;padding:40px"><h2>${message}</h2></body></html>`,
);
}
}
5 changes: 1 addition & 4 deletions src/email-digest/email-digest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ export class EmailDigestService {
});
}

async updatePreference(
userId: string,
data: { frequency?: DigestFrequency; enabled?: boolean },
) {
async updatePreference(userId: string, data: { frequency?: DigestFrequency; enabled?: boolean }) {
return this.prisma.digestPreference.upsert({
where: { userId },
update: data,
Expand Down
Loading
Loading