Skip to content

Commit 0fac3a8

Browse files
Merge pull request #407 from gabito1451/#comprehensive-asset-transfer-workflow
Implement comprehensive asset transfer workflow
2 parents 431198e + fcca1a7 commit 0fac3a8

23 files changed

+2425
-32
lines changed

backend/package-lock.json

Lines changed: 174 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@nestjs/swagger": "^7.3.0",
3333
"@nestjs/throttler": "^6.5.0",
3434
"@nestjs/typeorm": "^10.0.2",
35+
"@nestjs/websockets": "^10.4.15",
3536
"@types/multer": "^2.0.0",
3637
"@types/speakeasy": "^2.0.10",
3738
"@types/uuid": "^10.0.0",
@@ -55,6 +56,7 @@
5556
"redis": "^5.10.0",
5657
"reflect-metadata": "^0.2.0",
5758
"rxjs": "^7.8.1",
59+
"socket.io": "^4.8.1",
5860
"speakeasy": "^2.0.0",
5961
"swagger-ui-express": "^5.0.1",
6062
"typeorm": "^0.3.27"
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards } from '@nestjs/common';
2+
import { AssetTransfersService } from './asset-transfers.service';
3+
import { CreateTransferDto } from './dto/create-transfer.dto';
4+
import { ApproveTransferDto, RejectTransferDto } from './dto/approve-transfer.dto';
5+
import { TransferFilterDto } from './dto/transfer-filter.dto';
6+
7+
// Mock decorator since we don't have auth implemented yet
8+
const AuthGuard = () => {
9+
return (target: any, key?: string | symbol, descriptor?: PropertyDescriptor) => {
10+
// Mock implementation - in real auth, this would validate JWT
11+
};
12+
};
13+
const GetUser = () => {
14+
return (target: any, propertyKey: string, parameterIndex: number) => {
15+
// Mock implementation - in real auth, this would extract user from request
16+
};
17+
};
18+
19+
@Controller('transfers')
20+
export class AssetTransfersController {
21+
constructor(private readonly assetTransfersService: AssetTransfersService) {}
22+
23+
@Post()
24+
@UseGuards(AuthGuard())
25+
async createTransfer(
26+
@Body() createTransferDto: CreateTransferDto,
27+
@GetUser() user: any
28+
) {
29+
return await this.assetTransfersService.createTransfer(createTransferDto, user.id);
30+
}
31+
32+
@Get()
33+
@UseGuards(AuthGuard())
34+
async getTransfers(
35+
@Query() filterDto: TransferFilterDto,
36+
@GetUser() user: any
37+
) {
38+
return await this.assetTransfersService.getTransfers(filterDto, user.id);
39+
}
40+
41+
@Get(':id')
42+
@UseGuards(AuthGuard())
43+
async getTransferById(@Param('id') id: string) {
44+
return await this.assetTransfersService.getTransferById(id);
45+
}
46+
47+
@Put(':id/approve')
48+
@UseGuards(AuthGuard())
49+
async approveTransfer(
50+
@Param('id') id: string,
51+
@Body() approveDto: ApproveTransferDto,
52+
@GetUser() user: any
53+
) {
54+
return await this.assetTransfersService.approveTransfer(id, {
55+
...approveDto,
56+
approvedById: user.id
57+
});
58+
}
59+
60+
@Put(':id/reject')
61+
@UseGuards(AuthGuard())
62+
async rejectTransfer(
63+
@Param('id') id: string,
64+
@Body() rejectDto: RejectTransferDto,
65+
@GetUser() user: any
66+
) {
67+
return await this.assetTransfersService.rejectTransfer(id, {
68+
...rejectDto,
69+
rejectedById: user.id
70+
});
71+
}
72+
73+
@Delete(':id')
74+
@UseGuards(AuthGuard())
75+
async cancelTransfer(@Param('id') id: string, @GetUser() user: any) {
76+
return await this.assetTransfersService.cancelTransfer(id, user.id);
77+
}
78+
79+
@Get('notifications')
80+
@UseGuards(AuthGuard())
81+
async getNotifications(@GetUser() user: any) {
82+
return await this.assetTransfersService.getNotifications(user.id);
83+
}
84+
85+
@Put('notifications/:id/read')
86+
@UseGuards(AuthGuard())
87+
async markNotificationAsRead(
88+
@Param('id') notificationId: string,
89+
@GetUser() user: any
90+
) {
91+
return await this.assetTransfersService.markNotificationAsRead(notificationId, user.id);
92+
}
93+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Module } from '@nestjs/common';
2+
import { TypeOrmModule } from '@nestjs/typeorm';
3+
import { AssetTransfersController } from './asset-transfers.controller';
4+
import { AssetTransfersService } from './asset-transfers.service';
5+
import { AssetTransfer } from './entities/asset-transfer.entity';
6+
import { Notification } from './entities/notification.entity';
7+
import { TransferHistory } from './entities/transfer-history.entity';
8+
9+
@Module({
10+
imports: [
11+
TypeOrmModule.forFeature([AssetTransfer, Notification, TransferHistory]),
12+
],
13+
controllers: [AssetTransfersController],
14+
providers: [AssetTransfersService],
15+
exports: [AssetTransfersService],
16+
})
17+
export class AssetTransfersModule {}

0 commit comments

Comments
 (0)