jp.ms.common.modules 1.0.41 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.d.ts +3 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js +8 -4
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js.map +1 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.d.ts +6 -2
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js +37 -10
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js.map +1 -1
- package/dist/modules/base-achievements/base-achievements.module.js +2 -2
- package/dist/modules/base-achievements/base-achievements.module.js.map +1 -1
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.d.ts +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.js +5 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.js.map +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.d.ts +13 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.js +3 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.js.map +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.d.ts +15 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.js +77 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.js.map +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.d.ts +19 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.js +83 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.js.map +1 -0
- package/dist/modules/event-bus/events-bus.module.js +3 -0
- package/dist/modules/event-bus/events-bus.module.js.map +1 -1
- package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.d.ts +10 -0
- package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.js +26 -0
- package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.js.map +1 -0
- package/dist/modules/event-bus/index.d.ts +1 -0
- package/dist/modules/event-bus/index.js +3 -1
- package/dist/modules/event-bus/index.js.map +1 -1
- package/dist/modules/events/events.gateway.d.ts +6 -1
- package/dist/modules/events/events.gateway.js +15 -3
- package/dist/modules/events/events.gateway.js.map +1 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +3 -1
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/main/main.module.js +1 -1
- package/dist/modules/main/main.module.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.module.js +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +57 -57
- package/src/dto/app-screen/app-screen-app-bar.dto.ts +36 -36
- package/src/dto/app-screen/app-screen-dialog.dto.ts +64 -64
- package/src/dto/app-screen/app-screen-field-list-item.dto.ts +42 -42
- package/src/dto/app-screen/app-screen-field.dto.ts +59 -59
- package/src/dto/app-screen/app-screen-section-button.dto.ts +60 -60
- package/src/dto/app-screen/app-screen-section-buttons.dto.ts +14 -14
- package/src/dto/app-screen/app-screen-section-image.dto.ts +33 -33
- package/src/dto/app-screen/app-screen-section-list-item.dto.ts +105 -105
- package/src/dto/app-screen/app-screen-section-req.dto.ts +33 -33
- package/src/dto/app-screen/app-screen-section.dto.ts +76 -76
- package/src/dto/app-screen/app-screen.dto.ts +50 -50
- package/src/dto/app-screen/base-app-screen.dto.ts +16 -16
- package/src/dto/app-screen/index.ts +10 -10
- package/src/dto/app-table/bids-panel-item.dto.ts +33 -33
- package/src/dto/app-table/bids-panel.dto.ts +32 -32
- package/src/dto/app-table/card.dto.ts +54 -54
- package/src/dto/app-table/cards-deck.dto.ts +22 -22
- package/src/dto/app-table/cards-pair-slots-item.dto.ts +45 -45
- package/src/dto/app-table/cards-pair-slots.dto.ts +13 -13
- package/src/dto/app-table/cards-panel.dto.ts +48 -48
- package/src/dto/app-table/cards-player.dto.ts +14 -14
- package/src/dto/app-table/cards-slots-item.dto.ts +40 -40
- package/src/dto/app-table/cards-slots.dto.ts +13 -13
- package/src/dto/app-table/index.ts +15 -15
- package/src/dto/app-table/moves-panel-button.dto.ts +24 -24
- package/src/dto/app-table/moves-panel.dto.ts +23 -23
- package/src/dto/app-table/player.dto.ts +69 -69
- package/src/dto/app-table/summary-item.dto.ts +51 -51
- package/src/dto/app-table/summary.dto.ts +13 -13
- package/src/dto/common/find-free-table.dto.ts +3 -3
- package/src/dto/common/index.ts +2 -2
- package/src/dto/common/join-tournament.dto.ts +33 -33
- package/src/dto/common/log.dto.ts +9 -9
- package/src/dto/common/many-tables-tournament-create.dto.ts +125 -125
- package/src/dto/common/many-tables-tournament-update.dto.ts +3 -3
- package/src/dto/common/player-check-state.dto.ts +33 -33
- package/src/dto/common/player-connected.dto.ts +58 -58
- package/src/dto/games/fool/fool-player.dto.ts +3 -3
- package/src/dto/games/fool/fool-table.dto.ts +81 -81
- package/src/dto/games/index.ts +2 -2
- package/src/dto/games/poker/poker-player.dto.ts +3 -3
- package/src/dto/games/poker/poker-table.dto.ts +81 -81
- package/src/dto/index.ts +4 -4
- package/src/exception/error-code.enum.ts +4 -4
- package/src/exception/global-exception-filter.ts +53 -53
- package/src/exception/http-exception-wth-snackbar.ts +27 -27
- package/src/exception/index.ts +4 -4
- package/src/exception/not-enough-money-for-purchase.exception.ts +14 -14
- package/src/exception/not-found-free-room-for-fast-game.exception.ts +14 -14
- package/src/index.ts +4 -4
- package/src/modules/anti-freeze-system/anti-freeze-system.constants.ts +1 -1
- package/src/modules/anti-freeze-system/anti-freeze-system.interfaces.ts +20 -20
- package/src/modules/anti-freeze-system/anti-freeze-system.module.ts +59 -55
- package/src/modules/anti-freeze-system/anti-freeze-system.service.ts +136 -105
- package/src/modules/anti-freeze-system/index.ts +1 -1
- package/src/modules/base-achievements/base-achievements.module.ts +324 -322
- package/src/modules/base-achievements/index.ts +1 -1
- package/src/modules/confirmation-message-manager/confirmation-message-manager.constants.ts +3 -0
- package/src/modules/confirmation-message-manager/confirmation-message-manager.interfaces.ts +20 -0
- package/src/modules/confirmation-message-manager/confirmation-message-manager.module.ts +77 -0
- package/src/modules/confirmation-message-manager/confirmation-message-manager.service.ts +91 -0
- package/src/modules/event-bus/events-bus.app.subscribe.service.ts +20 -20
- package/src/modules/event-bus/events-bus.main-tables.subscribe.service.ts +34 -34
- package/src/modules/event-bus/events-bus.many-tables-tournament.subscribe.service.ts +6 -6
- package/src/modules/event-bus/events-bus.module.ts +26 -23
- package/src/modules/event-bus/events-bus.one-table-tournament.subscribe.service.ts +6 -6
- package/src/modules/event-bus/events-bus.player-ws-message.subscribe.service.ts +30 -0
- package/src/modules/event-bus/events-bus.tournament.subscribe.service.ts +18 -18
- package/src/modules/event-bus/index.ts +6 -5
- package/src/modules/events/events.constants.ts +1 -1
- package/src/modules/events/events.gateway.ts +82 -70
- package/src/modules/events/events.interfaces.ts +17 -17
- package/src/modules/events/events.module.ts +32 -32
- package/src/modules/events/index.ts +1 -1
- package/src/modules/index.ts +28 -27
- package/src/modules/logger/index.ts +2 -2
- package/src/modules/logger/jp-logger.module.ts +10 -10
- package/src/modules/logger/jp-logger.service.ts +38 -38
- package/src/modules/main/index.ts +1 -1
- package/src/modules/main/main-tables-list-screen.view.ts +275 -275
- package/src/modules/main/main.constants.ts +1 -1
- package/src/modules/main/main.controller.ts +72 -72
- package/src/modules/main/main.interfaces.ts +17 -17
- package/src/modules/main/main.module.ts +73 -73
- package/src/modules/main/main.service.ts +183 -183
- package/src/modules/many-tables-tournament/index.ts +1 -1
- package/src/modules/many-tables-tournament/many-tables-tournament-status-screen.view.ts +143 -143
- package/src/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.ts +63 -63
- package/src/modules/many-tables-tournament/many-tables-tournament.constants.ts +3 -3
- package/src/modules/many-tables-tournament/many-tables-tournament.controller.ts +151 -151
- package/src/modules/many-tables-tournament/many-tables-tournament.interfaces.ts +20 -20
- package/src/modules/many-tables-tournament/many-tables-tournament.module.ts +81 -80
- package/src/modules/many-tables-tournament/many-tables-tournament.service.ts +208 -208
- package/src/modules/many-tables-tournament-rooms-manager/index.ts +2 -2
- package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.constants.ts +3 -3
- package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.interfaces.ts +37 -37
- package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.module.ts +84 -84
- package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service.ts +331 -331
- package/src/modules/menu/index.ts +1 -1
- package/src/modules/menu/menu-screen.view.ts +71 -71
- package/src/modules/menu/menu.constants.ts +1 -1
- package/src/modules/menu/menu.controller.ts +16 -16
- package/src/modules/menu/menu.interfaces.ts +17 -17
- package/src/modules/menu/menu.module.ts +39 -39
- package/src/modules/menu/menu.service.ts +39 -39
- package/src/modules/one-table-tournament/index.ts +1 -1
- package/src/modules/one-table-tournament/one-table-tournament-status-screen.view.ts +166 -166
- package/src/modules/one-table-tournament/one-table-tournament.constants.ts +3 -3
- package/src/modules/one-table-tournament/one-table-tournament.controller.ts +104 -104
- package/src/modules/one-table-tournament/one-table-tournament.interfaces.ts +20 -20
- package/src/modules/one-table-tournament/one-table-tournament.module.ts +80 -76
- package/src/modules/one-table-tournament/one-table-tournament.service.ts +146 -146
- package/src/modules/one-table-tournament-rooms-manager/index.ts +2 -2
- package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.constants.ts +3 -3
- package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.interfaces.ts +31 -31
- package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.module.ts +66 -66
- package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.service.ts +220 -220
- package/src/modules/players-manager/index.ts +2 -2
- package/src/modules/players-manager/players-manager.module.ts +9 -9
- package/src/modules/players-manager/players-manager.service.ts +27 -27
- package/src/modules/simple-rooms/index.ts +1 -1
- package/src/modules/simple-rooms/simple-rooms.constants.ts +1 -1
- package/src/modules/simple-rooms/simple-rooms.controller.ts +63 -63
- package/src/modules/simple-rooms/simple-rooms.interfaces.ts +20 -20
- package/src/modules/simple-rooms/simple-rooms.module.ts +39 -39
- package/src/modules/simple-rooms/simple-rooms.service.ts +95 -95
- package/src/modules/simple-rooms-manager/index.ts +2 -2
- package/src/modules/simple-rooms-manager/simple-rooms-manager.constants.ts +3 -3
- package/src/modules/simple-rooms-manager/simple-rooms-manager.interfaces.ts +26 -26
- package/src/modules/simple-rooms-manager/simple-rooms-manager.module.ts +60 -60
- package/src/modules/simple-rooms-manager/simple-rooms-manager.service.ts +190 -190
- package/src/modules/support/dump.service.ts +11 -11
- package/src/modules/support/index.ts +1 -1
- package/src/modules/support/metric.service.ts +41 -41
- package/src/modules/support/support.constants.ts +1 -1
- package/src/modules/support/support.controller.ts +79 -79
- package/src/modules/support/support.interfaces.ts +16 -16
- package/src/modules/support/support.module.ts +35 -35
- package/src/modules/support/support.service.ts +27 -27
- package/src/utils/date.ts +7 -7
- package/src/utils/game-table-result.ts +129 -129
- package/src/views/index.ts +5 -5
- package/src/views/many-tables-tournament-conifrm-exit-dialog.view.ts +37 -37
- package/src/views/one-table-tournament-conifrm-exit-dialog.view.ts +37 -37
- package/src/views/simple-room-conifrm-exit-dialog.view.ts +37 -37
- package/src/views/table-summary.view.ts +104 -104
- package/src/views/tournament-buy-ticket-dialog.view.ts +34 -34
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
-
import { Expose, plainToInstance, Type } from 'class-transformer';
|
|
3
|
-
import { IsArray, IsNumber, ValidateNested } from 'class-validator';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { AppScreenAppBarDto, AppScreenDialogDto } from '../../app-screen';
|
|
7
|
-
import {
|
|
8
|
-
CardsPanelDto,
|
|
9
|
-
CardsSlotsDto,
|
|
10
|
-
MovesPanelDto,
|
|
11
|
-
SummaryDto,
|
|
12
|
-
BidsPanelDto,
|
|
13
|
-
} from '../../app-table';
|
|
14
|
-
|
|
15
|
-
import { PokerPlayerDto } from './poker-player.dto';
|
|
16
|
-
|
|
17
|
-
export class PokerTableDto implements IPokerTable {
|
|
18
|
-
@Type(() => AppScreenAppBarDto)
|
|
19
|
-
@Expose()
|
|
20
|
-
appBar: AppScreenAppBarDto;
|
|
21
|
-
|
|
22
|
-
@Type(() => AppScreenDialogDto)
|
|
23
|
-
@Expose()
|
|
24
|
-
confirmExitDialog: AppScreenDialogDto | undefined;
|
|
25
|
-
|
|
26
|
-
@ApiProperty({
|
|
27
|
-
description: 'Player Turn Timer Remain',
|
|
28
|
-
type: Number,
|
|
29
|
-
})
|
|
30
|
-
@IsNumber()
|
|
31
|
-
@Expose()
|
|
32
|
-
playersTurnTimer: number | undefined;
|
|
33
|
-
|
|
34
|
-
@ApiProperty({
|
|
35
|
-
description: 'Restart Timer Remain',
|
|
36
|
-
type: Number,
|
|
37
|
-
})
|
|
38
|
-
@IsNumber()
|
|
39
|
-
@Expose()
|
|
40
|
-
restartTimer: number | undefined;
|
|
41
|
-
|
|
42
|
-
@ApiProperty({
|
|
43
|
-
description: 'Table size',
|
|
44
|
-
type: Number,
|
|
45
|
-
})
|
|
46
|
-
@IsNumber()
|
|
47
|
-
@Expose()
|
|
48
|
-
tableSize: number;
|
|
49
|
-
|
|
50
|
-
@IsArray()
|
|
51
|
-
@ValidateNested({ each: true })
|
|
52
|
-
@Type(() => PokerPlayerDto)
|
|
53
|
-
@Expose()
|
|
54
|
-
players: PokerPlayerDto[];
|
|
55
|
-
|
|
56
|
-
@Type(() => CardsSlotsDto)
|
|
57
|
-
@Expose()
|
|
58
|
-
cardsSlots: CardsSlotsDto;
|
|
59
|
-
|
|
60
|
-
@Type(() => SummaryDto)
|
|
61
|
-
@Expose()
|
|
62
|
-
summary: SummaryDto;
|
|
63
|
-
|
|
64
|
-
@Type(() => CardsPanelDto)
|
|
65
|
-
@Expose()
|
|
66
|
-
cardsPanel: CardsPanelDto;
|
|
67
|
-
|
|
68
|
-
@Type(() => MovesPanelDto)
|
|
69
|
-
@Expose()
|
|
70
|
-
movesPanel: MovesPanelDto;
|
|
71
|
-
|
|
72
|
-
@Type(() => BidsPanelDto)
|
|
73
|
-
@Expose()
|
|
74
|
-
bidsPanel: BidsPanelDto;
|
|
75
|
-
|
|
76
|
-
constructor(entity: IPokerTable) {
|
|
77
|
-
return plainToInstance(PokerTableDto, entity, {
|
|
78
|
-
excludeExtraneousValues: true,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { Expose, plainToInstance, Type } from 'class-transformer';
|
|
3
|
+
import { IsArray, IsNumber, ValidateNested } from 'class-validator';
|
|
4
|
+
import { IPokerTable } from 'jp.common.models';
|
|
5
|
+
|
|
6
|
+
import { AppScreenAppBarDto, AppScreenDialogDto } from '../../app-screen';
|
|
7
|
+
import {
|
|
8
|
+
CardsPanelDto,
|
|
9
|
+
CardsSlotsDto,
|
|
10
|
+
MovesPanelDto,
|
|
11
|
+
SummaryDto,
|
|
12
|
+
BidsPanelDto,
|
|
13
|
+
} from '../../app-table';
|
|
14
|
+
|
|
15
|
+
import { PokerPlayerDto } from './poker-player.dto';
|
|
16
|
+
|
|
17
|
+
export class PokerTableDto implements IPokerTable {
|
|
18
|
+
@Type(() => AppScreenAppBarDto)
|
|
19
|
+
@Expose()
|
|
20
|
+
appBar: AppScreenAppBarDto;
|
|
21
|
+
|
|
22
|
+
@Type(() => AppScreenDialogDto)
|
|
23
|
+
@Expose()
|
|
24
|
+
confirmExitDialog: AppScreenDialogDto | undefined;
|
|
25
|
+
|
|
26
|
+
@ApiProperty({
|
|
27
|
+
description: 'Player Turn Timer Remain',
|
|
28
|
+
type: Number,
|
|
29
|
+
})
|
|
30
|
+
@IsNumber()
|
|
31
|
+
@Expose()
|
|
32
|
+
playersTurnTimer: number | undefined;
|
|
33
|
+
|
|
34
|
+
@ApiProperty({
|
|
35
|
+
description: 'Restart Timer Remain',
|
|
36
|
+
type: Number,
|
|
37
|
+
})
|
|
38
|
+
@IsNumber()
|
|
39
|
+
@Expose()
|
|
40
|
+
restartTimer: number | undefined;
|
|
41
|
+
|
|
42
|
+
@ApiProperty({
|
|
43
|
+
description: 'Table size',
|
|
44
|
+
type: Number,
|
|
45
|
+
})
|
|
46
|
+
@IsNumber()
|
|
47
|
+
@Expose()
|
|
48
|
+
tableSize: number;
|
|
49
|
+
|
|
50
|
+
@IsArray()
|
|
51
|
+
@ValidateNested({ each: true })
|
|
52
|
+
@Type(() => PokerPlayerDto)
|
|
53
|
+
@Expose()
|
|
54
|
+
players: PokerPlayerDto[];
|
|
55
|
+
|
|
56
|
+
@Type(() => CardsSlotsDto)
|
|
57
|
+
@Expose()
|
|
58
|
+
cardsSlots: CardsSlotsDto;
|
|
59
|
+
|
|
60
|
+
@Type(() => SummaryDto)
|
|
61
|
+
@Expose()
|
|
62
|
+
summary: SummaryDto;
|
|
63
|
+
|
|
64
|
+
@Type(() => CardsPanelDto)
|
|
65
|
+
@Expose()
|
|
66
|
+
cardsPanel: CardsPanelDto;
|
|
67
|
+
|
|
68
|
+
@Type(() => MovesPanelDto)
|
|
69
|
+
@Expose()
|
|
70
|
+
movesPanel: MovesPanelDto;
|
|
71
|
+
|
|
72
|
+
@Type(() => BidsPanelDto)
|
|
73
|
+
@Expose()
|
|
74
|
+
bidsPanel: BidsPanelDto;
|
|
75
|
+
|
|
76
|
+
constructor(entity: IPokerTable) {
|
|
77
|
+
return plainToInstance(PokerTableDto, entity, {
|
|
78
|
+
excludeExtraneousValues: true,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
package/src/dto/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './app-table';
|
|
2
|
-
export * from './app-screen';
|
|
3
|
-
export * from './common';
|
|
4
|
-
export * from './games';
|
|
1
|
+
export * from './app-table';
|
|
2
|
+
export * from './app-screen';
|
|
3
|
+
export * from './common';
|
|
4
|
+
export * from './games';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export enum ErrorCodeEnum {
|
|
2
|
-
NOT_ENOUGH_MONEY_FOR_PURCHASE = '1001',
|
|
3
|
-
NOT_FOUND_FREE_ROOM_FOR_FAST_GAME = '1002',
|
|
4
|
-
}
|
|
1
|
+
export enum ErrorCodeEnum {
|
|
2
|
+
NOT_ENOUGH_MONEY_FOR_PURCHASE = '1001',
|
|
3
|
+
NOT_FOUND_FREE_ROOM_FOR_FAST_GAME = '1002',
|
|
4
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ExceptionFilter,
|
|
3
|
-
Catch,
|
|
4
|
-
ArgumentsHost,
|
|
5
|
-
HttpException,
|
|
6
|
-
HttpStatus,
|
|
7
|
-
} from '@nestjs/common';
|
|
8
|
-
import { Response } from 'express';
|
|
9
|
-
|
|
10
|
-
import { JpLoggerService } from '../modules';
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
ErrorResponseWithSnackbar,
|
|
14
|
-
HttpExceptionWithSnackbar,
|
|
15
|
-
} from './http-exception-wth-snackbar';
|
|
16
|
-
|
|
17
|
-
@Catch(Error)
|
|
18
|
-
export class GlobalExceptionFilter implements ExceptionFilter {
|
|
19
|
-
private readonly logger = new JpLoggerService();
|
|
20
|
-
|
|
21
|
-
catch(exception: Error, host: ArgumentsHost) {
|
|
22
|
-
this.logger.error(exception);
|
|
23
|
-
const ctx = host.switchToHttp();
|
|
24
|
-
const response = ctx.getResponse<Response>();
|
|
25
|
-
|
|
26
|
-
if (exception instanceof HttpExceptionWithSnackbar) {
|
|
27
|
-
const data = exception.getResponse() as ErrorResponseWithSnackbar;
|
|
28
|
-
const status = exception.getStatus();
|
|
29
|
-
|
|
30
|
-
response.status(status).json({
|
|
31
|
-
statusCode: status,
|
|
32
|
-
message: exception.message,
|
|
33
|
-
snackbar: data.snackbar,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return;
|
|
37
|
-
} else if (exception instanceof HttpException) {
|
|
38
|
-
const status = exception.getStatus();
|
|
39
|
-
|
|
40
|
-
response.status(status).json({
|
|
41
|
-
statusCode: status,
|
|
42
|
-
message: exception.message,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
49
|
-
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
50
|
-
message: exception.message,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ExceptionFilter,
|
|
3
|
+
Catch,
|
|
4
|
+
ArgumentsHost,
|
|
5
|
+
HttpException,
|
|
6
|
+
HttpStatus,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import { Response } from 'express';
|
|
9
|
+
|
|
10
|
+
import { JpLoggerService } from '../modules';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
ErrorResponseWithSnackbar,
|
|
14
|
+
HttpExceptionWithSnackbar,
|
|
15
|
+
} from './http-exception-wth-snackbar';
|
|
16
|
+
|
|
17
|
+
@Catch(Error)
|
|
18
|
+
export class GlobalExceptionFilter implements ExceptionFilter {
|
|
19
|
+
private readonly logger = new JpLoggerService();
|
|
20
|
+
|
|
21
|
+
catch(exception: Error, host: ArgumentsHost) {
|
|
22
|
+
this.logger.error(exception);
|
|
23
|
+
const ctx = host.switchToHttp();
|
|
24
|
+
const response = ctx.getResponse<Response>();
|
|
25
|
+
|
|
26
|
+
if (exception instanceof HttpExceptionWithSnackbar) {
|
|
27
|
+
const data = exception.getResponse() as ErrorResponseWithSnackbar;
|
|
28
|
+
const status = exception.getStatus();
|
|
29
|
+
|
|
30
|
+
response.status(status).json({
|
|
31
|
+
statusCode: status,
|
|
32
|
+
message: exception.message,
|
|
33
|
+
snackbar: data.snackbar,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return;
|
|
37
|
+
} else if (exception instanceof HttpException) {
|
|
38
|
+
const status = exception.getStatus();
|
|
39
|
+
|
|
40
|
+
response.status(status).json({
|
|
41
|
+
statusCode: status,
|
|
42
|
+
message: exception.message,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
49
|
+
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
50
|
+
message: exception.message,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { HttpException, HttpStatus } from '@nestjs/common';
|
|
2
|
-
import { IAppScreenSnackbar } from 'jp.common.models';
|
|
3
|
-
|
|
4
|
-
import { ErrorCodeEnum } from './error-code.enum';
|
|
5
|
-
|
|
6
|
-
export interface ErrorResponseWithSnackbar {
|
|
7
|
-
statusCode: number;
|
|
8
|
-
message: string;
|
|
9
|
-
errorCode: string;
|
|
10
|
-
snackbar: IAppScreenSnackbar;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class HttpExceptionWithSnackbar extends HttpException {
|
|
14
|
-
constructor(
|
|
15
|
-
message: string,
|
|
16
|
-
errorCode: ErrorCodeEnum,
|
|
17
|
-
snackbar: IAppScreenSnackbar,
|
|
18
|
-
) {
|
|
19
|
-
const response: ErrorResponseWithSnackbar = {
|
|
20
|
-
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
21
|
-
message,
|
|
22
|
-
errorCode,
|
|
23
|
-
snackbar,
|
|
24
|
-
};
|
|
25
|
-
super(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
import { HttpException, HttpStatus } from '@nestjs/common';
|
|
2
|
+
import { IAppScreenSnackbar } from 'jp.common.models';
|
|
3
|
+
|
|
4
|
+
import { ErrorCodeEnum } from './error-code.enum';
|
|
5
|
+
|
|
6
|
+
export interface ErrorResponseWithSnackbar {
|
|
7
|
+
statusCode: number;
|
|
8
|
+
message: string;
|
|
9
|
+
errorCode: string;
|
|
10
|
+
snackbar: IAppScreenSnackbar;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class HttpExceptionWithSnackbar extends HttpException {
|
|
14
|
+
constructor(
|
|
15
|
+
message: string,
|
|
16
|
+
errorCode: ErrorCodeEnum,
|
|
17
|
+
snackbar: IAppScreenSnackbar,
|
|
18
|
+
) {
|
|
19
|
+
const response: ErrorResponseWithSnackbar = {
|
|
20
|
+
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
21
|
+
message,
|
|
22
|
+
errorCode,
|
|
23
|
+
snackbar,
|
|
24
|
+
};
|
|
25
|
+
super(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/exception/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { GlobalExceptionFilter } from './global-exception-filter';
|
|
2
|
-
export { NotEnoughMoneyForPurchaseException } from './not-enough-money-for-purchase.exception';
|
|
3
|
-
export { NotFoundFreeRoomForFastGameException } from './not-found-free-room-for-fast-game.exception';
|
|
4
|
-
export { ErrorCodeEnum } from './error-code.enum';
|
|
1
|
+
export { GlobalExceptionFilter } from './global-exception-filter';
|
|
2
|
+
export { NotEnoughMoneyForPurchaseException } from './not-enough-money-for-purchase.exception';
|
|
3
|
+
export { NotFoundFreeRoomForFastGameException } from './not-found-free-room-for-fast-game.exception';
|
|
4
|
+
export { ErrorCodeEnum } from './error-code.enum';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IAppScreenSnackbar } from 'jp.common.models';
|
|
2
|
-
|
|
3
|
-
import { ErrorCodeEnum } from './error-code.enum';
|
|
4
|
-
import { HttpExceptionWithSnackbar } from './http-exception-wth-snackbar';
|
|
5
|
-
|
|
6
|
-
export class NotEnoughMoneyForPurchaseException extends HttpExceptionWithSnackbar {
|
|
7
|
-
constructor(snackbar: IAppScreenSnackbar) {
|
|
8
|
-
super(
|
|
9
|
-
'Not enough money for purchase',
|
|
10
|
-
ErrorCodeEnum.NOT_ENOUGH_MONEY_FOR_PURCHASE,
|
|
11
|
-
snackbar,
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { IAppScreenSnackbar } from 'jp.common.models';
|
|
2
|
+
|
|
3
|
+
import { ErrorCodeEnum } from './error-code.enum';
|
|
4
|
+
import { HttpExceptionWithSnackbar } from './http-exception-wth-snackbar';
|
|
5
|
+
|
|
6
|
+
export class NotEnoughMoneyForPurchaseException extends HttpExceptionWithSnackbar {
|
|
7
|
+
constructor(snackbar: IAppScreenSnackbar) {
|
|
8
|
+
super(
|
|
9
|
+
'Not enough money for purchase',
|
|
10
|
+
ErrorCodeEnum.NOT_ENOUGH_MONEY_FOR_PURCHASE,
|
|
11
|
+
snackbar,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IAppScreenSnackbar } from 'jp.common.models';
|
|
2
|
-
|
|
3
|
-
import { ErrorCodeEnum } from './error-code.enum';
|
|
4
|
-
import { HttpExceptionWithSnackbar } from './http-exception-wth-snackbar';
|
|
5
|
-
|
|
6
|
-
export class NotFoundFreeRoomForFastGameException extends HttpExceptionWithSnackbar {
|
|
7
|
-
constructor(snackbar: IAppScreenSnackbar) {
|
|
8
|
-
super(
|
|
9
|
-
'Not found free room for fast game',
|
|
10
|
-
ErrorCodeEnum.NOT_FOUND_FREE_ROOM_FOR_FAST_GAME,
|
|
11
|
-
snackbar,
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { IAppScreenSnackbar } from 'jp.common.models';
|
|
2
|
+
|
|
3
|
+
import { ErrorCodeEnum } from './error-code.enum';
|
|
4
|
+
import { HttpExceptionWithSnackbar } from './http-exception-wth-snackbar';
|
|
5
|
+
|
|
6
|
+
export class NotFoundFreeRoomForFastGameException extends HttpExceptionWithSnackbar {
|
|
7
|
+
constructor(snackbar: IAppScreenSnackbar) {
|
|
8
|
+
super(
|
|
9
|
+
'Not found free room for fast game',
|
|
10
|
+
ErrorCodeEnum.NOT_FOUND_FREE_ROOM_FOR_FAST_GAME,
|
|
11
|
+
snackbar,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './dto';
|
|
2
|
-
export * from './modules';
|
|
3
|
-
export * from './exception';
|
|
4
|
-
export * from './views';
|
|
1
|
+
export * from './dto';
|
|
2
|
+
export * from './modules';
|
|
3
|
+
export * from './exception';
|
|
4
|
+
export * from './views';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ANTI_FREEZE_SYSTEM_OPTIONS = Symbol('ANTI_FREEZE_SYSTEM_OPTIONS');
|
|
1
|
+
export const ANTI_FREEZE_SYSTEM_OPTIONS = Symbol('ANTI_FREEZE_SYSTEM_OPTIONS');
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
-
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
3
|
-
import { DynamicModule } from '@nestjs/common/interfaces/modules/dynamic-module.interface';
|
|
4
|
-
import { ForwardReference } from '@nestjs/common/interfaces/modules/forward-reference.interface';
|
|
5
|
-
|
|
6
|
-
export interface AntiFreezeSystemOptions extends Pick<
|
|
7
|
-
ModuleMetadata,
|
|
8
|
-
'imports'
|
|
9
|
-
> {
|
|
10
|
-
imports?: Array<
|
|
11
|
-
Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference
|
|
12
|
-
>;
|
|
13
|
-
inject?: any[];
|
|
14
|
-
useFactory?: (...args: any[]) => AntiFreezeSystemFactoryOptions;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AntiFreezeSystemFactoryOptions {
|
|
18
|
-
antiFreezeSystemTime: string;
|
|
19
|
-
antiFreezeSystemCheckCount: number;
|
|
20
|
-
}
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
3
|
+
import { DynamicModule } from '@nestjs/common/interfaces/modules/dynamic-module.interface';
|
|
4
|
+
import { ForwardReference } from '@nestjs/common/interfaces/modules/forward-reference.interface';
|
|
5
|
+
|
|
6
|
+
export interface AntiFreezeSystemOptions extends Pick<
|
|
7
|
+
ModuleMetadata,
|
|
8
|
+
'imports'
|
|
9
|
+
> {
|
|
10
|
+
imports?: Array<
|
|
11
|
+
Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference
|
|
12
|
+
>;
|
|
13
|
+
inject?: any[];
|
|
14
|
+
useFactory?: (...args: any[]) => AntiFreezeSystemFactoryOptions;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AntiFreezeSystemFactoryOptions {
|
|
18
|
+
antiFreezeSystemTime: string;
|
|
19
|
+
antiFreezeSystemCheckCount: number;
|
|
20
|
+
}
|
|
@@ -1,55 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DynamicModule,
|
|
3
|
-
Global,
|
|
4
|
-
Inject,
|
|
5
|
-
Module,
|
|
6
|
-
Provider,
|
|
7
|
-
} from '@nestjs/common';
|
|
8
|
-
import schedule, { Job } from 'node-schedule';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
private readonly
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
import {
|
|
2
|
+
DynamicModule,
|
|
3
|
+
Global,
|
|
4
|
+
Inject,
|
|
5
|
+
Module,
|
|
6
|
+
Provider,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import schedule, { Job } from 'node-schedule';
|
|
9
|
+
|
|
10
|
+
import { JpLoggerService } from '../logger';
|
|
11
|
+
|
|
12
|
+
import { AntiFreezeSystemService } from './anti-freeze-system.service';
|
|
13
|
+
import { ANTI_FREEZE_SYSTEM_OPTIONS } from './anti-freeze-system.constants';
|
|
14
|
+
import {
|
|
15
|
+
AntiFreezeSystemFactoryOptions,
|
|
16
|
+
AntiFreezeSystemOptions,
|
|
17
|
+
} from './anti-freeze-system.interfaces';
|
|
18
|
+
|
|
19
|
+
@Global()
|
|
20
|
+
@Module({
|
|
21
|
+
providers: [AntiFreezeSystemService],
|
|
22
|
+
})
|
|
23
|
+
export class AntiFreezeSystemModule {
|
|
24
|
+
private antiFreezeSystemJob: Job;
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
private readonly antiFreezeSystemService: AntiFreezeSystemService,
|
|
28
|
+
@Inject(ANTI_FREEZE_SYSTEM_OPTIONS)
|
|
29
|
+
private readonly options: AntiFreezeSystemFactoryOptions,
|
|
30
|
+
@Inject() private readonly logger: JpLoggerService,
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
static forRootAsync(options: AntiFreezeSystemOptions): DynamicModule {
|
|
34
|
+
return {
|
|
35
|
+
module: AntiFreezeSystemModule,
|
|
36
|
+
imports: options.imports ?? [],
|
|
37
|
+
providers: [
|
|
38
|
+
{
|
|
39
|
+
provide: ANTI_FREEZE_SYSTEM_OPTIONS,
|
|
40
|
+
useFactory: options.useFactory,
|
|
41
|
+
inject: options.inject || [],
|
|
42
|
+
} as Provider,
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onModuleInit() {
|
|
48
|
+
const antiFreezeSystemTime = this.options.antiFreezeSystemTime;
|
|
49
|
+
|
|
50
|
+
if (antiFreezeSystemTime) {
|
|
51
|
+
this.logger.log(`${AntiFreezeSystemModule.name}: scheduleJob`);
|
|
52
|
+
|
|
53
|
+
this.antiFreezeSystemJob = schedule.scheduleJob(
|
|
54
|
+
antiFreezeSystemTime,
|
|
55
|
+
() => this.antiFreezeSystemService.process(),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|