Skip to content

Commit 2b37288

Browse files
committed
fix: missing swagger errors
1 parent 9f2a175 commit 2b37288

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

libs/contract/constants/errors/errors.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,4 +1024,9 @@ export const ERRORS = {
10241024
message: 'Generic reorder error',
10251025
httpCode: 500,
10261026
},
1027+
HWID_DEVICE_NOT_FOUND: {
1028+
code: 'A204',
1029+
message: 'HWID device not found',
1030+
httpCode: 404,
1031+
},
10271032
} as const;

libs/contract/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remnawave/backend-contract",
3-
"version": "2.3.19",
3+
"version": "2.3.20",
44
"public": true,
55
"license": "AGPL-3.0-only",
66
"description": "A contract library for Remnawave Backend. It can be used in backend and frontend.",

src/modules/hwid-user-devices/hwid-user-devices.controller.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
import {
2+
ApiBearerAuth,
3+
ApiNotFoundResponse,
4+
ApiOkResponse,
5+
ApiParam,
6+
ApiQuery,
7+
ApiTags,
8+
} from '@nestjs/swagger';
19
import { Body, Controller, HttpStatus, Param, Query, UseFilters, UseGuards } from '@nestjs/common';
2-
import { ApiBearerAuth, ApiOkResponse, ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger';
310

411
import { HttpExceptionFilter } from '@common/exception/http-exception.filter';
512
import { JwtDefaultGuard } from '@common/guards/jwt-guards/def-jwt-guard';
@@ -85,6 +92,9 @@ export class HwidUserDevicesController {
8592
};
8693
}
8794

95+
@ApiNotFoundResponse({
96+
description: 'One of requested resources not found',
97+
})
8898
@ApiOkResponse({
8999
type: CreateUserHwidDeviceResponseDto,
90100
description: 'User HWID device created successfully',
@@ -108,6 +118,9 @@ export class HwidUserDevicesController {
108118
};
109119
}
110120

121+
@ApiNotFoundResponse({
122+
description: 'One of requested resources not found',
123+
})
111124
@ApiOkResponse({
112125
type: DeleteUserHwidDeviceResponseDto,
113126
description: 'User HWID device deleted successfully',
@@ -134,6 +147,9 @@ export class HwidUserDevicesController {
134147
};
135148
}
136149

150+
@ApiNotFoundResponse({
151+
description: 'One of requested resources not found',
152+
})
137153
@ApiOkResponse({
138154
type: DeleteAllUserHwidDevicesResponseDto,
139155
description: 'User HWID devices deleted successfully',
@@ -174,6 +190,9 @@ export class HwidUserDevicesController {
174190
};
175191
}
176192

193+
@ApiNotFoundResponse({
194+
description: 'One of requested resources not found',
195+
})
177196
@ApiOkResponse({
178197
type: GetUserHwidDevicesResponseDto,
179198
description: 'User HWID devices fetched successfully',

src/modules/hwid-user-devices/hwid-user-devices.service.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,23 @@ export class HwidUserDevicesService {
196196
userUuid,
197197
});
198198

199+
if (!hwidDevice) {
200+
return {
201+
isOk: false,
202+
...ERRORS.HWID_DEVICE_NOT_FOUND,
203+
};
204+
}
205+
199206
await this.hwidUserDevicesRepository.deleteByHwidAndUserUuid(hwid, userUuid);
200207

201-
if (hwidDevice) {
202-
this.eventEmitter.emit(
208+
this.eventEmitter.emit(
209+
EVENTS.USER_HWID_DEVICES.DELETED,
210+
new UserHwidDeviceEvent(
211+
user.response,
212+
hwidDevice,
203213
EVENTS.USER_HWID_DEVICES.DELETED,
204-
new UserHwidDeviceEvent(
205-
user.response,
206-
hwidDevice,
207-
EVENTS.USER_HWID_DEVICES.DELETED,
208-
),
209-
);
210-
}
214+
),
215+
);
211216

212217
const userHwidDevices = await this.hwidUserDevicesRepository.findByCriteria({
213218
userUuid,

0 commit comments

Comments
 (0)