• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-client-gateway / 13068911825

31 Jan 2025 08:17AM UTC coverage: 90.938% (+0.005%) from 90.933%
13068911825

Pull #2315

github

iamacook
fix: add initial tests
Pull Request #2315: feat(users): add route logic

2943 of 3555 branches covered (82.78%)

Branch coverage included in aggregate %.

36 of 42 new or added lines in 6 files covered. (85.71%)

1 existing line in 1 file now uncovered.

9761 of 10415 relevant lines covered (93.72%)

506.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
/src/routes/users/users.controller.ts
1
import {
114✔
2
  ApiBadRequestResponse,
3
  ApiConflictResponse,
4
  ApiNotFoundResponse,
5
  ApiOkResponse,
6
  ApiTags,
7
} from '@nestjs/swagger';
8
import {
114✔
9
  Controller,
10
  Delete,
11
  Get,
12
  Param,
13
  Post,
14
  UseGuards,
15
} from '@nestjs/common';
16
import { AuthGuard } from '@/routes/auth/guards/auth.guard';
114✔
17
import { Auth } from '@/routes/auth/decorators/auth.decorator';
114✔
18
import { UsersService } from '@/routes/users/users.service';
114✔
19
import { ValidationPipe } from '@/validation/pipes/validation.pipe';
114✔
20
import { AddressSchema } from '@/validation/entities/schemas/address.schema';
114✔
21
import { UserWithWallets } from '@/routes/users/entities/user-with-wallets.entity';
114✔
22
import { CreatedUserWithWallet } from '@/routes/users/entities/created-user-with-wallet.entity';
114✔
23
import type { AuthPayload } from '@/domain/auth/entities/auth-payload.entity';
24

25
@ApiTags('users')
26
@Controller({ path: 'users', version: '1' })
27
export class UsersController {
114✔
28
  public constructor(private readonly usersService: UsersService) {}
2✔
29

30
  @ApiOkResponse({ type: UserWithWallets })
31
  @ApiNotFoundResponse({ description: 'User not found' })
32
  @Get()
33
  @UseGuards(AuthGuard)
34
  public async getUseWithWallets(
114✔
35
    @Auth() authPayload: AuthPayload,
36
  ): Promise<UserWithWallets> {
37
    return await this.usersService.getUserWithWallets(authPayload);
2✔
38
  }
39

40
  @ApiConflictResponse({ description: 'Could not delete user' })
41
  @Delete()
42
  @UseGuards(AuthGuard)
43
  public async deleteUser(@Auth() authPayload: AuthPayload): Promise<void> {
114✔
NEW
44
    return await this.usersService.deleteUser(authPayload);
×
45
  }
46

47
  @ApiOkResponse({ type: CreatedUserWithWallet })
48
  @ApiConflictResponse({
49
    description: 'A wallet with the same address already exists',
50
  })
51
  @Post('/wallet')
52
  @UseGuards(AuthGuard)
53
  public async createUserWithWallet(
114✔
54
    @Auth() authPayload: AuthPayload,
55
  ): Promise<CreatedUserWithWallet> {
NEW
56
    return await this.usersService.createUserWithWallet(authPayload);
×
57
  }
58

59
  @ApiConflictResponse({
60
    description:
61
      'Cannot remove the current wallet OR User could not be remove from wallet',
62
  })
63
  @ApiNotFoundResponse({ description: 'User not found' })
64
  @ApiBadRequestResponse({
65
    description: 'Cannot delete the last wallet of a user',
66
  })
67
  @ApiOkResponse({ description: 'Wallet removed from user and deleted' })
68
  @Delete('/wallet/:walletAddress')
69
  @UseGuards(AuthGuard)
70
  public async deleteWalletFromUser(
114✔
71
    @Param('walletAddress', new ValidationPipe(AddressSchema))
72
    walletAddress: `0x${string}`,
73
    @Auth() authPayload: AuthPayload,
74
  ): Promise<void> {
NEW
75
    return await this.usersService.deleteWalletFromUser({
×
76
      authPayload,
77
      walletAddress,
78
    });
79
  }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc