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
174 changes: 174 additions & 0 deletions backend/package-lock.json

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

2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@nestjs/swagger": "^7.3.0",
"@nestjs/throttler": "^6.5.0",
"@nestjs/typeorm": "^10.0.2",
"@nestjs/websockets": "^10.4.15",
"@types/multer": "^2.0.0",
"@types/speakeasy": "^2.0.10",
"@types/uuid": "^10.0.0",
Expand All @@ -55,6 +56,7 @@
"redis": "^5.10.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"socket.io": "^4.8.1",
"speakeasy": "^2.0.0",
"swagger-ui-express": "^5.0.1",
"typeorm": "^0.3.27"
Expand Down
93 changes: 93 additions & 0 deletions backend/src/asset-transfers/asset-transfers.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards } from '@nestjs/common';
import { AssetTransfersService } from './asset-transfers.service';
import { CreateTransferDto } from './dto/create-transfer.dto';
import { ApproveTransferDto, RejectTransferDto } from './dto/approve-transfer.dto';
import { TransferFilterDto } from './dto/transfer-filter.dto';

// Mock decorator since we don't have auth implemented yet
const AuthGuard = () => {
return (target: any, key?: string | symbol, descriptor?: PropertyDescriptor) => {
// Mock implementation - in real auth, this would validate JWT
};
};
const GetUser = () => {
return (target: any, propertyKey: string, parameterIndex: number) => {
// Mock implementation - in real auth, this would extract user from request
};
};

@Controller('transfers')
export class AssetTransfersController {
constructor(private readonly assetTransfersService: AssetTransfersService) {}

@Post()
@UseGuards(AuthGuard())
async createTransfer(
@Body() createTransferDto: CreateTransferDto,
@GetUser() user: any
) {
return await this.assetTransfersService.createTransfer(createTransferDto, user.id);
}

@Get()
@UseGuards(AuthGuard())
async getTransfers(
@Query() filterDto: TransferFilterDto,
@GetUser() user: any
) {
return await this.assetTransfersService.getTransfers(filterDto, user.id);
}

@Get(':id')
@UseGuards(AuthGuard())
async getTransferById(@Param('id') id: string) {
return await this.assetTransfersService.getTransferById(id);
}

@Put(':id/approve')
@UseGuards(AuthGuard())
async approveTransfer(
@Param('id') id: string,
@Body() approveDto: ApproveTransferDto,
@GetUser() user: any
) {
return await this.assetTransfersService.approveTransfer(id, {
...approveDto,
approvedById: user.id
});
}

@Put(':id/reject')
@UseGuards(AuthGuard())
async rejectTransfer(
@Param('id') id: string,
@Body() rejectDto: RejectTransferDto,
@GetUser() user: any
) {
return await this.assetTransfersService.rejectTransfer(id, {
...rejectDto,
rejectedById: user.id
});
}

@Delete(':id')
@UseGuards(AuthGuard())
async cancelTransfer(@Param('id') id: string, @GetUser() user: any) {
return await this.assetTransfersService.cancelTransfer(id, user.id);
}

@Get('notifications')
@UseGuards(AuthGuard())
async getNotifications(@GetUser() user: any) {
return await this.assetTransfersService.getNotifications(user.id);
}

@Put('notifications/:id/read')
@UseGuards(AuthGuard())
async markNotificationAsRead(
@Param('id') notificationId: string,
@GetUser() user: any
) {
return await this.assetTransfersService.markNotificationAsRead(notificationId, user.id);
}
}
17 changes: 17 additions & 0 deletions backend/src/asset-transfers/asset-transfers.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AssetTransfersController } from './asset-transfers.controller';
import { AssetTransfersService } from './asset-transfers.service';
import { AssetTransfer } from './entities/asset-transfer.entity';
import { Notification } from './entities/notification.entity';
import { TransferHistory } from './entities/transfer-history.entity';

@Module({
imports: [
TypeOrmModule.forFeature([AssetTransfer, Notification, TransferHistory]),
],
controllers: [AssetTransfersController],
providers: [AssetTransfersService],
exports: [AssetTransfersService],
})
export class AssetTransfersModule {}
Loading
Loading