@omnitronix/game-engine-sdk 1.0.1

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.
Files changed (177) hide show
  1. package/dist/bootstrap/index.d.ts +15 -0
  2. package/dist/bootstrap/index.d.ts.map +1 -0
  3. package/dist/bootstrap/index.js +156 -0
  4. package/dist/common/api-docs/setup-documentation.d.ts +3 -0
  5. package/dist/common/api-docs/setup-documentation.d.ts.map +1 -0
  6. package/dist/common/api-docs/setup-documentation.js +27 -0
  7. package/dist/common/application-bootstrap-options.interface.d.ts +4 -0
  8. package/dist/common/application-bootstrap-options.interface.d.ts.map +1 -0
  9. package/dist/common/application-bootstrap-options.interface.js +2 -0
  10. package/dist/common/error-handling/all-exceptions.filter.d.ts +22 -0
  11. package/dist/common/error-handling/all-exceptions.filter.d.ts.map +1 -0
  12. package/dist/common/error-handling/all-exceptions.filter.js +131 -0
  13. package/dist/common/error-handling/domain.exception.d.ts +8 -0
  14. package/dist/common/error-handling/domain.exception.d.ts.map +1 -0
  15. package/dist/common/error-handling/domain.exception.js +14 -0
  16. package/dist/common/error-handling/error-code-mapper.d.ts +6 -0
  17. package/dist/common/error-handling/error-code-mapper.d.ts.map +1 -0
  18. package/dist/common/error-handling/error-code-mapper.js +93 -0
  19. package/dist/common/error-handling/internal-error-code.d.ts +67 -0
  20. package/dist/common/error-handling/internal-error-code.d.ts.map +1 -0
  21. package/dist/common/error-handling/internal-error-code.js +80 -0
  22. package/dist/common/index.d.ts +21 -0
  23. package/dist/common/index.d.ts.map +1 -0
  24. package/dist/common/index.js +51 -0
  25. package/dist/common/logger/logger.d.ts +24 -0
  26. package/dist/common/logger/logger.d.ts.map +1 -0
  27. package/dist/common/logger/logger.js +137 -0
  28. package/dist/common/logger/logger.module.d.ts +3 -0
  29. package/dist/common/logger/logger.module.d.ts.map +1 -0
  30. package/dist/common/logger/logger.module.js +19 -0
  31. package/dist/common/logger/logging.middleware.d.ts +8 -0
  32. package/dist/common/logger/logging.middleware.d.ts.map +1 -0
  33. package/dist/common/logger/logging.middleware.js +44 -0
  34. package/dist/common/metrics/database-metrics.service.d.ts +8 -0
  35. package/dist/common/metrics/database-metrics.service.d.ts.map +1 -0
  36. package/dist/common/metrics/database-metrics.service.js +39 -0
  37. package/dist/common/metrics/helpers/metrics.helpers.d.ts +5 -0
  38. package/dist/common/metrics/helpers/metrics.helpers.d.ts.map +1 -0
  39. package/dist/common/metrics/helpers/metrics.helpers.js +38 -0
  40. package/dist/common/metrics/metrics.module.d.ts +3 -0
  41. package/dist/common/metrics/metrics.module.d.ts.map +1 -0
  42. package/dist/common/metrics/metrics.module.js +207 -0
  43. package/dist/common/metrics/metrics.port.d.ts +22 -0
  44. package/dist/common/metrics/metrics.port.d.ts.map +1 -0
  45. package/dist/common/metrics/metrics.port.js +4 -0
  46. package/dist/common/metrics/prometheus.service.d.ts +25 -0
  47. package/dist/common/metrics/prometheus.service.d.ts.map +1 -0
  48. package/dist/common/metrics/prometheus.service.js +105 -0
  49. package/dist/common/retry/retry-policies.d.ts +8 -0
  50. package/dist/common/retry/retry-policies.d.ts.map +1 -0
  51. package/dist/common/retry/retry-policies.js +43 -0
  52. package/dist/common/retry/retry-policy.d.ts +25 -0
  53. package/dist/common/retry/retry-policy.d.ts.map +1 -0
  54. package/dist/common/retry/retry-policy.js +65 -0
  55. package/dist/common/secrets-provider/secrets-provider.aws.d.ts +13 -0
  56. package/dist/common/secrets-provider/secrets-provider.aws.d.ts.map +1 -0
  57. package/dist/common/secrets-provider/secrets-provider.aws.js +72 -0
  58. package/dist/common/secrets-provider/secrets-provider.d.ts +5 -0
  59. package/dist/common/secrets-provider/secrets-provider.d.ts.map +1 -0
  60. package/dist/common/secrets-provider/secrets-provider.js +4 -0
  61. package/dist/common/secrets-provider/secrets-provider.local.d.ts +8 -0
  62. package/dist/common/secrets-provider/secrets-provider.local.d.ts.map +1 -0
  63. package/dist/common/secrets-provider/secrets-provider.local.js +75 -0
  64. package/dist/common/secrets-provider/secrets-provider.module.d.ts +5 -0
  65. package/dist/common/secrets-provider/secrets-provider.module.d.ts.map +1 -0
  66. package/dist/common/secrets-provider/secrets-provider.module.js +47 -0
  67. package/dist/esm/bootstrap/index.js +120 -0
  68. package/dist/esm/common/api-docs/setup-documentation.js +23 -0
  69. package/dist/esm/common/application-bootstrap-options.interface.js +1 -0
  70. package/dist/esm/common/error-handling/all-exceptions.filter.js +128 -0
  71. package/dist/esm/common/error-handling/domain.exception.js +10 -0
  72. package/dist/esm/common/error-handling/error-code-mapper.js +89 -0
  73. package/dist/esm/common/error-handling/internal-error-code.js +77 -0
  74. package/dist/esm/common/index.js +25 -0
  75. package/dist/esm/common/logger/logger.js +133 -0
  76. package/dist/esm/common/logger/logger.module.js +16 -0
  77. package/dist/esm/common/logger/logging.middleware.js +41 -0
  78. package/dist/esm/common/metrics/database-metrics.service.js +36 -0
  79. package/dist/esm/common/metrics/helpers/metrics.helpers.js +32 -0
  80. package/dist/esm/common/metrics/metrics.module.js +204 -0
  81. package/dist/esm/common/metrics/metrics.port.js +1 -0
  82. package/dist/esm/common/metrics/prometheus.service.js +102 -0
  83. package/dist/esm/common/retry/retry-policies.js +39 -0
  84. package/dist/esm/common/retry/retry-policy.js +61 -0
  85. package/dist/esm/common/secrets-provider/secrets-provider.aws.js +69 -0
  86. package/dist/esm/common/secrets-provider/secrets-provider.js +1 -0
  87. package/dist/esm/common/secrets-provider/secrets-provider.local.js +39 -0
  88. package/dist/esm/common/secrets-provider/secrets-provider.module.js +44 -0
  89. package/dist/esm/generated/game-engine-registry_pb.js +28 -0
  90. package/dist/esm/generated/game-engine_pb.js +57 -0
  91. package/dist/esm/grpc/connect-router.middleware.js +16 -0
  92. package/dist/esm/grpc/game-engine.grpc.in-adapter.js +109 -0
  93. package/dist/esm/grpc/index.js +2 -0
  94. package/dist/esm/health/application/ports/in/health-in.port.js +1 -0
  95. package/dist/esm/health/application/ports/out/database-health.out-port.js +1 -0
  96. package/dist/esm/health/application/ports/out/shutdown.out-port.js +1 -0
  97. package/dist/esm/health/application/ports/out/system-health.out-port.js +1 -0
  98. package/dist/esm/health/application/services/health.service.js +81 -0
  99. package/dist/esm/health/domain/health.js +7 -0
  100. package/dist/esm/health/health.module.js +65 -0
  101. package/dist/esm/health/index.js +15 -0
  102. package/dist/esm/health/infrastructure/adapters/in/health.http.in-adapter.js +96 -0
  103. package/dist/esm/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.js +45 -0
  104. package/dist/esm/health/infrastructure/adapters/out/system/system-health.out-adapter.js +43 -0
  105. package/dist/esm/index.js +15 -0
  106. package/dist/esm/registration/adapters/game-engine-registry.grpc.out-adapter.js +59 -0
  107. package/dist/esm/registration/index.js +3 -0
  108. package/dist/esm/registration/ports/game-engine-registry.out-port.js +1 -0
  109. package/dist/esm/registration/services/game-engine-auto-register.service.js +78 -0
  110. package/dist/esm/types.js +8 -0
  111. package/dist/generated/game-engine-registry_pb.d.ts +76 -0
  112. package/dist/generated/game-engine-registry_pb.d.ts.map +1 -0
  113. package/dist/generated/game-engine-registry_pb.js +31 -0
  114. package/dist/generated/game-engine_pb.d.ts +171 -0
  115. package/dist/generated/game-engine_pb.d.ts.map +1 -0
  116. package/dist/generated/game-engine_pb.js +60 -0
  117. package/dist/grpc/connect-router.middleware.d.ts +7 -0
  118. package/dist/grpc/connect-router.middleware.d.ts.map +1 -0
  119. package/dist/grpc/connect-router.middleware.js +19 -0
  120. package/dist/grpc/game-engine.grpc.in-adapter.d.ts +21 -0
  121. package/dist/grpc/game-engine.grpc.in-adapter.d.ts.map +1 -0
  122. package/dist/grpc/game-engine.grpc.in-adapter.js +112 -0
  123. package/dist/grpc/index.d.ts +3 -0
  124. package/dist/grpc/index.d.ts.map +1 -0
  125. package/dist/grpc/index.js +7 -0
  126. package/dist/health/application/ports/in/health-in.port.d.ts +7 -0
  127. package/dist/health/application/ports/in/health-in.port.d.ts.map +1 -0
  128. package/dist/health/application/ports/in/health-in.port.js +4 -0
  129. package/dist/health/application/ports/out/database-health.out-port.d.ts +6 -0
  130. package/dist/health/application/ports/out/database-health.out-port.d.ts.map +1 -0
  131. package/dist/health/application/ports/out/database-health.out-port.js +4 -0
  132. package/dist/health/application/ports/out/shutdown.out-port.d.ts +6 -0
  133. package/dist/health/application/ports/out/shutdown.out-port.d.ts.map +1 -0
  134. package/dist/health/application/ports/out/shutdown.out-port.js +4 -0
  135. package/dist/health/application/ports/out/system-health.out-port.d.ts +7 -0
  136. package/dist/health/application/ports/out/system-health.out-port.d.ts.map +1 -0
  137. package/dist/health/application/ports/out/system-health.out-port.js +4 -0
  138. package/dist/health/application/services/health.service.d.ts +13 -0
  139. package/dist/health/application/services/health.service.d.ts.map +1 -0
  140. package/dist/health/application/services/health.service.js +84 -0
  141. package/dist/health/domain/health.d.ts +15 -0
  142. package/dist/health/domain/health.d.ts.map +1 -0
  143. package/dist/health/domain/health.js +11 -0
  144. package/dist/health/health.module.d.ts +10 -0
  145. package/dist/health/health.module.d.ts.map +1 -0
  146. package/dist/health/health.module.js +68 -0
  147. package/dist/health/index.d.ts +11 -0
  148. package/dist/health/index.d.ts.map +1 -0
  149. package/dist/health/index.js +28 -0
  150. package/dist/health/infrastructure/adapters/in/health.http.in-adapter.d.ts +16 -0
  151. package/dist/health/infrastructure/adapters/in/health.http.in-adapter.d.ts.map +1 -0
  152. package/dist/health/infrastructure/adapters/in/health.http.in-adapter.js +99 -0
  153. package/dist/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.d.ts +13 -0
  154. package/dist/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.d.ts.map +1 -0
  155. package/dist/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.js +48 -0
  156. package/dist/health/infrastructure/adapters/out/system/system-health.out-adapter.d.ts +12 -0
  157. package/dist/health/infrastructure/adapters/out/system/system-health.out-adapter.d.ts.map +1 -0
  158. package/dist/health/infrastructure/adapters/out/system/system-health.out-adapter.js +46 -0
  159. package/dist/index.d.ts +9 -0
  160. package/dist/index.d.ts.map +1 -0
  161. package/dist/index.js +43 -0
  162. package/dist/registration/adapters/game-engine-registry.grpc.out-adapter.d.ts +12 -0
  163. package/dist/registration/adapters/game-engine-registry.grpc.out-adapter.d.ts.map +1 -0
  164. package/dist/registration/adapters/game-engine-registry.grpc.out-adapter.js +62 -0
  165. package/dist/registration/index.d.ts +4 -0
  166. package/dist/registration/index.d.ts.map +1 -0
  167. package/dist/registration/index.js +9 -0
  168. package/dist/registration/ports/game-engine-registry.out-port.d.ts +9 -0
  169. package/dist/registration/ports/game-engine-registry.out-port.d.ts.map +1 -0
  170. package/dist/registration/ports/game-engine-registry.out-port.js +4 -0
  171. package/dist/registration/services/game-engine-auto-register.service.d.ts +14 -0
  172. package/dist/registration/services/game-engine-auto-register.service.d.ts.map +1 -0
  173. package/dist/registration/services/game-engine-auto-register.service.js +81 -0
  174. package/dist/types.d.ts +53 -0
  175. package/dist/types.d.ts.map +1 -0
  176. package/dist/types.js +11 -0
  177. package/package.json +159 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets-provider.local.d.ts","sourceRoot":"","sources":["../../../src/common/secrets-provider/secrets-provider.local.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBACa,oBAAqB,YAAW,eAAe;IAC1D,OAAO,CAAC,YAAY,CAAkC;;IAMtD,OAAO,CAAC,WAAW;IAUb,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAM/C"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.LocalSecretsProvider = void 0;
46
+ const common_1 = require("@nestjs/common");
47
+ const dotenv = __importStar(require("dotenv"));
48
+ const fs = __importStar(require("fs"));
49
+ const path = __importStar(require("path"));
50
+ let LocalSecretsProvider = class LocalSecretsProvider {
51
+ constructor() {
52
+ this.secretsCache = new Map();
53
+ this.loadSecrets();
54
+ }
55
+ loadSecrets() {
56
+ const envPath = path.resolve(process.cwd(), '.secrets.env');
57
+ if (fs.existsSync(envPath)) {
58
+ const parsed = dotenv.parse(fs.readFileSync(envPath));
59
+ Object.entries(parsed).forEach(([key, value]) => {
60
+ this.secretsCache.set(key, value);
61
+ });
62
+ }
63
+ }
64
+ async get(secretName) {
65
+ if (this.secretsCache.has(secretName)) {
66
+ return this.secretsCache.get(secretName);
67
+ }
68
+ throw new Error(`Secret ${secretName} not found in local secrets file`);
69
+ }
70
+ };
71
+ exports.LocalSecretsProvider = LocalSecretsProvider;
72
+ exports.LocalSecretsProvider = LocalSecretsProvider = __decorate([
73
+ (0, common_1.Injectable)(),
74
+ __metadata("design:paramtypes", [])
75
+ ], LocalSecretsProvider);
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export declare class SecretsModule {
3
+ static register(): DynamicModule;
4
+ }
5
+ //# sourceMappingURL=secrets-provider.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets-provider.module.d.ts","sourceRoot":"","sources":["../../../src/common/secrets-provider/secrets-provider.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAO/D,qBAIa,aAAa;IACxB,MAAM,CAAC,QAAQ,IAAI,aAAa;CAsBjC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var SecretsModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SecretsModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const config_1 = require("@nestjs/config");
13
+ const secrets_provider_1 = require("./secrets-provider");
14
+ const secrets_provider_aws_1 = require("./secrets-provider.aws");
15
+ const secrets_provider_local_1 = require("./secrets-provider.local");
16
+ let SecretsModule = SecretsModule_1 = class SecretsModule {
17
+ static register() {
18
+ return {
19
+ module: SecretsModule_1,
20
+ providers: [
21
+ {
22
+ provide: secrets_provider_1.SECRETS_PROVIDER,
23
+ useFactory: async (configService) => {
24
+ const useLocalSecrets = configService.get('LOCAL_SECRETS') === 'true';
25
+ if (useLocalSecrets) {
26
+ return new secrets_provider_local_1.LocalSecretsProvider();
27
+ }
28
+ else {
29
+ const awsSecretsProvider = new secrets_provider_aws_1.AwsSecretsProvider(configService);
30
+ await awsSecretsProvider.register();
31
+ return awsSecretsProvider;
32
+ }
33
+ },
34
+ inject: [config_1.ConfigService],
35
+ },
36
+ ],
37
+ exports: [secrets_provider_1.SECRETS_PROVIDER],
38
+ };
39
+ }
40
+ };
41
+ exports.SecretsModule = SecretsModule;
42
+ exports.SecretsModule = SecretsModule = SecretsModule_1 = __decorate([
43
+ (0, common_1.Global)(),
44
+ (0, common_1.Module)({
45
+ imports: [config_1.ConfigModule],
46
+ })
47
+ ], SecretsModule);
@@ -0,0 +1,120 @@
1
+ import { Logger } from '../common/logger/logger';
2
+ import { ExceptionsFilter } from '../common/error-handling/all-exceptions.filter';
3
+ import { InternalErrorCode } from '../common/error-handling/internal-error-code';
4
+ import { setupDocumentation } from '../common/api-docs/setup-documentation';
5
+ import { SHUTDOWN_OUT_PORT, } from '../health/application/ports/out/shutdown.out-port';
6
+ import { GameEngineGrpcInAdapter } from '../grpc/game-engine.grpc.in-adapter';
7
+ import { createConnectRouter } from '../grpc/connect-router.middleware';
8
+ import { BadRequestException, RequestMethod, ValidationPipe } from '@nestjs/common';
9
+ import { ConfigService } from '@nestjs/config';
10
+ import { NestFactory } from '@nestjs/core';
11
+ import * as http2 from 'http2';
12
+ /**
13
+ * Creates and bootstraps a game engine NestJS application with
14
+ * standard configuration: CORS, validation pipes, exception filters,
15
+ * Swagger docs, Connect RPC gRPC server, and graceful shutdown.
16
+ */
17
+ export async function createGameEngineApp(options) {
18
+ const { serviceName, appModule, bootstrapOptions } = options;
19
+ const logger = new Logger(serviceName);
20
+ const moduleArg = bootstrapOptions
21
+ ? appModule.register
22
+ ? appModule.register(bootstrapOptions)
23
+ : appModule
24
+ : appModule;
25
+ const app = await NestFactory.create(moduleArg, {
26
+ logger: logger,
27
+ });
28
+ app.enableCors({ origin: true });
29
+ const configService = app.get(ConfigService);
30
+ const shutdownService = app.get(SHUTDOWN_OUT_PORT);
31
+ let isShuttingDown = false;
32
+ const handleFatalError = async (errorType, error) => {
33
+ logger.error(`${errorType}:`, {
34
+ error: error.message,
35
+ stack: error.stack,
36
+ });
37
+ if (isShuttingDown) {
38
+ logger.warn('Shutdown already in progress, ignoring additional error');
39
+ return;
40
+ }
41
+ isShuttingDown = true;
42
+ try {
43
+ logger.warn(`Initiating graceful shutdown due to ${errorType}...`);
44
+ await shutdownService.startGracefulShutdown();
45
+ logger.log('Graceful shutdown completed, exiting process');
46
+ }
47
+ catch (shutdownError) {
48
+ logger.error('Error during graceful shutdown:', shutdownError);
49
+ }
50
+ finally {
51
+ process.exit(1);
52
+ }
53
+ };
54
+ process.on('uncaughtException', (error) => {
55
+ logger.error('Uncaught Exception:', {
56
+ error: error.message,
57
+ stack: error.stack,
58
+ });
59
+ void handleFatalError('uncaughtException', error);
60
+ });
61
+ process.on('unhandledRejection', (reason, promise) => {
62
+ logger.error('Unhandled Rejection:', {
63
+ reason: reason.message,
64
+ stack: reason.stack,
65
+ promise,
66
+ });
67
+ void handleFatalError('unhandledRejection', reason);
68
+ });
69
+ app.setGlobalPrefix('api', {
70
+ exclude: [
71
+ { path: 'health', method: RequestMethod.GET },
72
+ { path: 'ready', method: RequestMethod.GET },
73
+ { path: 'metrics', method: RequestMethod.GET },
74
+ ],
75
+ });
76
+ app.useGlobalPipes(new ValidationPipe({
77
+ whitelist: true,
78
+ forbidNonWhitelisted: true,
79
+ transform: true,
80
+ exceptionFactory: errors => {
81
+ const messages = errors.map(error => Object.values(error.constraints || {}).join(', '));
82
+ return new BadRequestException({
83
+ statusCode: 400,
84
+ internalCode: InternalErrorCode.VALIDATION_ERROR,
85
+ message: messages,
86
+ timestamp: new Date().toISOString(),
87
+ path: '/api',
88
+ });
89
+ },
90
+ }));
91
+ app.useGlobalFilters(app.get(ExceptionsFilter));
92
+ const PORT = configService.get('PORT') || 3000;
93
+ await setupDocumentation(app, PORT, serviceName);
94
+ // Setup Connect RPC server
95
+ const gameEngineAdapter = app.get(GameEngineGrpcInAdapter);
96
+ const connectRouter = createConnectRouter(gameEngineAdapter);
97
+ // Mount Connect router on /connect path
98
+ app.use('/connect', connectRouter);
99
+ app.enableShutdownHooks(['SIGTERM', 'SIGINT']);
100
+ // Start separate h2c (HTTP/2 cleartext) server for Connect RPC
101
+ const GRPC_PORT = configService.get('GRPC_PORT', 50051);
102
+ const h2cServer = http2.createServer({}, connectRouter);
103
+ h2cServer.on('error', (err) => {
104
+ logger.error('h2c gRPC server error:', err);
105
+ });
106
+ h2cServer.listen(GRPC_PORT, '0.0.0.0', () => {
107
+ logger.log(`Connect RPC (h2c) is available on: http://localhost:${GRPC_PORT}`);
108
+ });
109
+ // Close h2c server during graceful shutdown
110
+ const closeH2c = () => {
111
+ h2cServer.close(() => {
112
+ logger.log('h2c gRPC server closed');
113
+ });
114
+ };
115
+ process.on('SIGTERM', closeH2c);
116
+ process.on('SIGINT', closeH2c);
117
+ await app.listen(PORT, '0.0.0.0');
118
+ logger.log(`Application is running on: http://localhost:${PORT}`);
119
+ return app;
120
+ }
@@ -0,0 +1,23 @@
1
+ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
2
+ import { Logger } from '../logger/logger';
3
+ const logger = new Logger('ApiDocs');
4
+ export const setupDocumentation = async (app, port, serviceName) => {
5
+ const config = new DocumentBuilder()
6
+ .setTitle(serviceName ? `${serviceName} API` : 'Game Engine API')
7
+ .setDescription('API documentation')
8
+ .setOpenAPIVersion('3.0.0')
9
+ .build();
10
+ const document = SwaggerModule.createDocument(app, config);
11
+ SwaggerModule.setup('docs', app, document, {
12
+ jsonDocumentUrl: 'docs/json',
13
+ yamlDocumentUrl: 'docs/yaml',
14
+ swaggerOptions: {
15
+ tagsSorter: 'alpha',
16
+ operationsSorter: 'alpha',
17
+ docExpansion: 'list',
18
+ filter: true,
19
+ showRequestHeaders: true,
20
+ },
21
+ });
22
+ logger.log(`Documentation is available on: http://localhost:${port}/docs`);
23
+ };
@@ -0,0 +1,128 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ var ExceptionsFilter_1;
14
+ import { Logger } from '../logger/logger';
15
+ import { METRICS_PORT } from '../metrics/metrics.port';
16
+ import { Catch, HttpException, HttpStatus, Inject, } from '@nestjs/common';
17
+ import { DomainException } from './domain.exception';
18
+ import { ErrorCodeMapper } from './error-code-mapper';
19
+ import { InternalErrorCode } from './internal-error-code';
20
+ let ExceptionsFilter = ExceptionsFilter_1 = class ExceptionsFilter {
21
+ constructor(metricsPort) {
22
+ this.metricsPort = metricsPort;
23
+ this.logger = new Logger(ExceptionsFilter_1.name);
24
+ }
25
+ catch(exception, host) {
26
+ const ctx = host.switchToHttp();
27
+ const response = ctx.getResponse();
28
+ const request = ctx.getRequest();
29
+ const errorResponse = this.buildErrorResponse(exception, request);
30
+ response.status(errorResponse.statusCode).json(errorResponse);
31
+ }
32
+ buildErrorResponse(exception, request) {
33
+ if (exception instanceof DomainException) {
34
+ return this.handleDomainException(exception, request);
35
+ }
36
+ if (exception instanceof HttpException) {
37
+ return this.handleHttpException(exception, request);
38
+ }
39
+ if (exception instanceof Error) {
40
+ return this.handleGenericError(exception, request);
41
+ }
42
+ return this.handleUnknownError(exception, request);
43
+ }
44
+ handleDomainException(exception, request) {
45
+ const status = ErrorCodeMapper.mapToHttpStatus(exception.errorCode);
46
+ const level = status >= 500 ? 'error' : 'warn';
47
+ this.logger.log(`DomainException (status: ${status} at ${request.method} ${request.url}): Internal Code ${exception.errorCode} Message: ${exception.message}`, { level });
48
+ if (exception.cause) {
49
+ this.logger.error('Exception cause:', exception.cause);
50
+ }
51
+ return this.buildResponsePayload({
52
+ status,
53
+ internalCode: exception.errorCode,
54
+ message: exception.message,
55
+ path: request.url,
56
+ });
57
+ }
58
+ handleHttpException(exception, request) {
59
+ const status = exception.getStatus();
60
+ const responseData = exception.getResponse();
61
+ // Check if this is a custom validation error response
62
+ if (typeof responseData === 'object' &&
63
+ responseData.internalCode &&
64
+ responseData.statusCode) {
65
+ return responseData;
66
+ }
67
+ let message = 'HTTP Exception';
68
+ if (typeof responseData === 'string') {
69
+ message = responseData;
70
+ }
71
+ else if (typeof responseData === 'object' && responseData.message) {
72
+ message = responseData.message;
73
+ }
74
+ const level = status >= 500 ? 'error' : 'warn';
75
+ this.logger.log(`HttpException (status: ${status} at ${request.method} ${request.url}): ${message}`, { level });
76
+ if (status === 401 || status === 403) {
77
+ const internalCode = status === 401 ? InternalErrorCode.UNAUTHORIZED : InternalErrorCode.FORBIDDEN;
78
+ return this.buildResponsePayload({
79
+ status,
80
+ internalCode,
81
+ message,
82
+ path: request.url,
83
+ });
84
+ }
85
+ if (status === HttpStatus.INTERNAL_SERVER_ERROR) {
86
+ this.logger.error('HttpException stack:', exception.stack);
87
+ }
88
+ return this.buildResponsePayload({
89
+ status,
90
+ internalCode: InternalErrorCode.INTERNAL_SERVER_ERROR,
91
+ message,
92
+ path: request.url,
93
+ });
94
+ }
95
+ handleGenericError(exception, request) {
96
+ this.logger.error(`Unhandled Error (status: ${HttpStatus.INTERNAL_SERVER_ERROR} at ${request.method} ${request.url}): ${exception.stack}`);
97
+ return this.buildResponsePayload({
98
+ status: HttpStatus.INTERNAL_SERVER_ERROR,
99
+ internalCode: InternalErrorCode.INTERNAL_SERVER_ERROR,
100
+ message: exception.message,
101
+ path: request.url,
102
+ });
103
+ }
104
+ handleUnknownError(exception, request) {
105
+ this.logger.error(`Unknown error type (status: ${HttpStatus.INTERNAL_SERVER_ERROR} at ${request.method} ${request.url}): ${String(exception)}`);
106
+ return this.buildResponsePayload({
107
+ status: HttpStatus.INTERNAL_SERVER_ERROR,
108
+ internalCode: InternalErrorCode.INTERNAL_SERVER_ERROR,
109
+ message: 'Internal server error',
110
+ path: request.url,
111
+ });
112
+ }
113
+ buildResponsePayload({ status, internalCode, message, path, }) {
114
+ return {
115
+ statusCode: status,
116
+ internalCode,
117
+ message,
118
+ timestamp: new Date().toISOString(),
119
+ path,
120
+ };
121
+ }
122
+ };
123
+ ExceptionsFilter = ExceptionsFilter_1 = __decorate([
124
+ Catch(),
125
+ __param(0, Inject(METRICS_PORT)),
126
+ __metadata("design:paramtypes", [Object])
127
+ ], ExceptionsFilter);
128
+ export { ExceptionsFilter };
@@ -0,0 +1,10 @@
1
+ export class DomainException extends Error {
2
+ constructor(errorCode, message, cause) {
3
+ super(message);
4
+ this.errorCode = errorCode;
5
+ this.message = message;
6
+ this.cause = cause;
7
+ this.name = 'DomainException';
8
+ this.cause = cause;
9
+ }
10
+ }
@@ -0,0 +1,89 @@
1
+ import { InternalErrorCode } from './internal-error-code';
2
+ // HTTP status codes
3
+ const HttpStatus = {
4
+ BAD_REQUEST: 400,
5
+ CONFLICT: 409,
6
+ FORBIDDEN: 403,
7
+ NOT_FOUND: 404,
8
+ UNPROCESSABLE_ENTITY: 422,
9
+ INTERNAL_SERVER_ERROR: 500,
10
+ SERVICE_UNAVAILABLE: 503,
11
+ };
12
+ export class ErrorCodeMapper {
13
+ static mapToHttpStatus(errorCode) {
14
+ return this.ERROR_CODE_TO_HTTP_MAP[errorCode] || HttpStatus.BAD_REQUEST;
15
+ }
16
+ }
17
+ ErrorCodeMapper.ERROR_CODE_TO_HTTP_MAP = {
18
+ [InternalErrorCode.FORBIDDEN]: HttpStatus.FORBIDDEN,
19
+ [InternalErrorCode.INVALID_CURRENCY_CODE]: HttpStatus.BAD_REQUEST,
20
+ [InternalErrorCode.INSUFFICIENT_FUNDS]: HttpStatus.UNPROCESSABLE_ENTITY,
21
+ [InternalErrorCode.INTERNAL_SERVER_ERROR]: HttpStatus.INTERNAL_SERVER_ERROR,
22
+ // Game Catalog errors
23
+ [InternalErrorCode.GAME_NOT_FOUND]: HttpStatus.NOT_FOUND,
24
+ [InternalErrorCode.GAME_CONFIG_NOT_FOUND]: HttpStatus.NOT_FOUND,
25
+ [InternalErrorCode.GAME_CONFIG_ALREADY_EXISTS_WITH_SAME_JURISDICTION_AND_RTP]: HttpStatus.BAD_REQUEST,
26
+ [InternalErrorCode.OPERATOR_GAME_NOT_FOUND]: HttpStatus.NOT_FOUND,
27
+ [InternalErrorCode.OPERATOR_GAME_ALREADY_ENABLED]: HttpStatus.BAD_REQUEST,
28
+ [InternalErrorCode.INVALID_GAME_CONFIG_DATA]: HttpStatus.BAD_REQUEST,
29
+ [InternalErrorCode.INVALID_GAME_UPDATE_DATA]: HttpStatus.BAD_REQUEST,
30
+ [InternalErrorCode.GAME_CODE_ALREADY_EXISTS]: HttpStatus.BAD_REQUEST,
31
+ [InternalErrorCode.GAME_OR_GAME_CONFIG_DISABLED]: HttpStatus.BAD_REQUEST,
32
+ [InternalErrorCode.DEBUG_COMMANDS_DISABLED]: HttpStatus.FORBIDDEN,
33
+ // Game Orchestrator errors
34
+ [InternalErrorCode.INVALID_SESSION]: HttpStatus.BAD_REQUEST,
35
+ [InternalErrorCode.SESSION_NOT_FOUND]: HttpStatus.NOT_FOUND,
36
+ [InternalErrorCode.SESSION_NOT_ACTIVE]: HttpStatus.BAD_REQUEST,
37
+ [InternalErrorCode.SESSION_MISMATCH]: HttpStatus.BAD_REQUEST,
38
+ [InternalErrorCode.INVALID_STATE_TRANSITION]: HttpStatus.BAD_REQUEST,
39
+ [InternalErrorCode.INVALID_BET_AMOUNT]: HttpStatus.BAD_REQUEST,
40
+ [InternalErrorCode.REALITY_CHECK_IN_PROGRESS]: HttpStatus.BAD_REQUEST,
41
+ [InternalErrorCode.UNKNOWN_COMMAND]: HttpStatus.NOT_FOUND,
42
+ // Operator errors
43
+ [InternalErrorCode.MISSING_OPERATOR_CODE]: HttpStatus.BAD_REQUEST,
44
+ [InternalErrorCode.INVALID_OPERATOR_CODE]: HttpStatus.BAD_REQUEST,
45
+ [InternalErrorCode.OPERATOR_NOT_FOUND]: HttpStatus.NOT_FOUND,
46
+ [InternalErrorCode.OPERATOR_INACTIVE]: HttpStatus.FORBIDDEN,
47
+ [InternalErrorCode.COUNTRY_CODE_RESTRICTED]: HttpStatus.BAD_REQUEST,
48
+ [InternalErrorCode.UNAUTHORIZED]: HttpStatus.FORBIDDEN,
49
+ [InternalErrorCode.AUTH_VALIDATION_FAILED]: HttpStatus.FORBIDDEN,
50
+ [InternalErrorCode.BALANCE_NOT_FOUND]: HttpStatus.NOT_FOUND,
51
+ [InternalErrorCode.INVALID_AUTH_DATA]: HttpStatus.BAD_REQUEST,
52
+ [InternalErrorCode.VALIDATION_ERROR]: HttpStatus.BAD_REQUEST,
53
+ [InternalErrorCode.JURISDICTION_CONFIG_ALREADY_EXISTS]: HttpStatus.BAD_REQUEST,
54
+ [InternalErrorCode.JURISDICTION_CONFIG_NOT_FOUND]: HttpStatus.NOT_FOUND,
55
+ [InternalErrorCode.OPERATOR_JURISDICTION_CONFIG_NOT_FOUND]: HttpStatus.NOT_FOUND,
56
+ [InternalErrorCode.GAME_ENGINE_ERROR]: HttpStatus.INTERNAL_SERVER_ERROR,
57
+ [InternalErrorCode.DEBIT_FAILED]: HttpStatus.BAD_REQUEST,
58
+ [InternalErrorCode.CREDIT_FAILED]: HttpStatus.BAD_REQUEST,
59
+ [InternalErrorCode.GAME_ROUND_LOG_NOT_FOUND]: HttpStatus.NOT_FOUND,
60
+ // Geo Validation errors
61
+ [InternalErrorCode.COUNTRY_NOT_PERMITTED]: HttpStatus.FORBIDDEN,
62
+ [InternalErrorCode.GEO_VALIDATION_SERVICE_UNAVAILABLE]: HttpStatus.INTERNAL_SERVER_ERROR,
63
+ [InternalErrorCode.RESOURCE_NOT_FOUND]: HttpStatus.NOT_FOUND,
64
+ [InternalErrorCode.FINANCIAL_TRANSACTION_NOT_FOUND]: HttpStatus.NOT_FOUND,
65
+ [InternalErrorCode.SESSION_TERMINATED]: HttpStatus.BAD_REQUEST,
66
+ [InternalErrorCode.SESSION_CANNOT_BE_TERMINATED]: HttpStatus.BAD_REQUEST,
67
+ [InternalErrorCode.SESSION_AUTO_RESOLVE_FAILED]: HttpStatus.BAD_REQUEST,
68
+ [InternalErrorCode.SESSION_ALREADY_EXISTS]: HttpStatus.BAD_REQUEST,
69
+ [InternalErrorCode.INCOMPATIBLE_GAMEPLAY_CONFIG]: HttpStatus.BAD_REQUEST,
70
+ // Health check errors
71
+ [InternalErrorCode.HEALTH_CHECK_FAILED]: HttpStatus.SERVICE_UNAVAILABLE,
72
+ //Jackpot errors
73
+ [InternalErrorCode.JACKPOT_TYPE_NOT_FOUND]: HttpStatus.NOT_FOUND,
74
+ [InternalErrorCode.JACKPOT_TIER_NOT_FOUND]: HttpStatus.NOT_FOUND,
75
+ [InternalErrorCode.JACKPOT_CONFIGURATION_NOT_FOUND]: HttpStatus.NOT_FOUND,
76
+ [InternalErrorCode.JACKPOT_CONFIGURATION_IS_ACTIVE]: HttpStatus.BAD_REQUEST,
77
+ // RNG and Replay errors
78
+ [InternalErrorCode.RNG_SEED_NOT_FOUND]: HttpStatus.NOT_FOUND,
79
+ [InternalErrorCode.RNG_SEED_MISMATCH]: HttpStatus.BAD_REQUEST,
80
+ [InternalErrorCode.MASTER_HASH_INVALID]: HttpStatus.BAD_REQUEST,
81
+ [InternalErrorCode.REPLAY_OUTCOME_MISMATCH]: HttpStatus.BAD_REQUEST,
82
+ [InternalErrorCode.JACKPOT_POOL_CONTRIBUTION_ALREADY_PROCESSED]: HttpStatus.INTERNAL_SERVER_ERROR,
83
+ [InternalErrorCode.JACKPOT_TYPE_DOES_NOT_SUPPORT_TIERS]: HttpStatus.BAD_REQUEST,
84
+ [InternalErrorCode.CONCURRENT_MODIFICATION]: HttpStatus.CONFLICT,
85
+ [InternalErrorCode.ACCOUNT_LOCKED]: HttpStatus.FORBIDDEN,
86
+ [InternalErrorCode.DAILY_LIMIT_EXCEEDED]: HttpStatus.UNPROCESSABLE_ENTITY,
87
+ [InternalErrorCode.INVALID_AMOUNT]: HttpStatus.BAD_REQUEST,
88
+ [InternalErrorCode.SERVICE_UNAVAILABLE]: HttpStatus.SERVICE_UNAVAILABLE,
89
+ };
@@ -0,0 +1,77 @@
1
+ export var InternalErrorCode;
2
+ (function (InternalErrorCode) {
3
+ InternalErrorCode["FORBIDDEN"] = "FORBIDDEN";
4
+ InternalErrorCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
5
+ InternalErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
6
+ InternalErrorCode["INVALID_CURRENCY_CODE"] = "INVALID_CURRENCY_CODE";
7
+ // Game Catalog errors
8
+ InternalErrorCode["GAME_NOT_FOUND"] = "GAME_NOT_FOUND";
9
+ InternalErrorCode["GAME_CONFIG_NOT_FOUND"] = "GAME_CONFIG_NOT_FOUND";
10
+ InternalErrorCode["GAME_CONFIG_ALREADY_EXISTS_WITH_SAME_JURISDICTION_AND_RTP"] = "GAME_CONFIG_ALREADY_EXISTS_WITH_SAME_JURISDICTION_AND_RTP";
11
+ InternalErrorCode["OPERATOR_GAME_NOT_FOUND"] = "OPERATOR_GAME_NOT_FOUND";
12
+ InternalErrorCode["OPERATOR_GAME_ALREADY_ENABLED"] = "OPERATOR_GAME_ALREADY_ENABLED";
13
+ InternalErrorCode["INVALID_GAME_CONFIG_DATA"] = "INVALID_GAME_CONFIG_DATA";
14
+ InternalErrorCode["INVALID_GAME_UPDATE_DATA"] = "INVALID_GAME_UPDATE_DATA";
15
+ InternalErrorCode["GAME_CODE_ALREADY_EXISTS"] = "GAME_CODE_ALREADY_EXISTS";
16
+ InternalErrorCode["GAME_ENGINE_ERROR"] = "GAME_ENGINE_ERROR";
17
+ InternalErrorCode["GAME_OR_GAME_CONFIG_DISABLED"] = "GAME_OR_GAME_CONFIG_DISABLED";
18
+ InternalErrorCode["DEBUG_COMMANDS_DISABLED"] = "DEBUG_COMMANDS_DISABLED";
19
+ // Game Orchestrator errors
20
+ InternalErrorCode["INVALID_SESSION"] = "INVALID_SESSION";
21
+ InternalErrorCode["SESSION_NOT_FOUND"] = "SESSION_NOT_FOUND";
22
+ InternalErrorCode["SESSION_NOT_ACTIVE"] = "SESSION_NOT_ACTIVE";
23
+ InternalErrorCode["SESSION_MISMATCH"] = "SESSION_MISMATCH";
24
+ InternalErrorCode["INVALID_STATE_TRANSITION"] = "INVALID_STATE_TRANSITION";
25
+ InternalErrorCode["INVALID_BET_AMOUNT"] = "INVALID_BET_AMOUNT";
26
+ InternalErrorCode["REALITY_CHECK_IN_PROGRESS"] = "REALITY_CHECK_IN_PROGRESS";
27
+ InternalErrorCode["SESSION_TERMINATED"] = "SESSION_TERMINATED";
28
+ InternalErrorCode["SESSION_CANNOT_BE_TERMINATED"] = "SESSION_CANNOT_BE_TERMINATED";
29
+ InternalErrorCode["SESSION_AUTO_RESOLVE_FAILED"] = "SESSION_AUTO_RESOLVE_FAILED";
30
+ InternalErrorCode["SESSION_ALREADY_EXISTS"] = "SESSION_ALREADY_EXISTS";
31
+ InternalErrorCode["INCOMPATIBLE_GAMEPLAY_CONFIG"] = "INCOMPATIBLE_GAMEPLAY_CONFIG";
32
+ InternalErrorCode["UNKNOWN_COMMAND"] = "UNKNOWN_COMMAND";
33
+ // Operator errors
34
+ InternalErrorCode["MISSING_OPERATOR_CODE"] = "MISSING_OPERATOR_CODE";
35
+ InternalErrorCode["INVALID_OPERATOR_CODE"] = "INVALID_OPERATOR_CODE";
36
+ InternalErrorCode["OPERATOR_NOT_FOUND"] = "OPERATOR_NOT_FOUND";
37
+ InternalErrorCode["OPERATOR_INACTIVE"] = "OPERATOR_INACTIVE";
38
+ InternalErrorCode["COUNTRY_CODE_RESTRICTED"] = "COUNTRY_CODE_RESTRICTED";
39
+ InternalErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
40
+ InternalErrorCode["AUTH_VALIDATION_FAILED"] = "AUTH_VALIDATION_FAILED";
41
+ InternalErrorCode["BALANCE_NOT_FOUND"] = "BALANCE_NOT_FOUND";
42
+ InternalErrorCode["DEBIT_FAILED"] = "DEBIT_FAILED";
43
+ InternalErrorCode["CREDIT_FAILED"] = "CREDIT_FAILED";
44
+ InternalErrorCode["INVALID_AUTH_DATA"] = "INVALID_AUTH_DATA";
45
+ InternalErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
46
+ InternalErrorCode["JURISDICTION_CONFIG_ALREADY_EXISTS"] = "JURISDICTION_CONFIG_ALREADY_EXISTS";
47
+ InternalErrorCode["JURISDICTION_CONFIG_NOT_FOUND"] = "JURISDICTION_CONFIG_NOT_FOUND";
48
+ InternalErrorCode["OPERATOR_JURISDICTION_CONFIG_NOT_FOUND"] = "OPERATOR_JURISDICTION_CONFIG_NOT_FOUND";
49
+ // Game round log errors
50
+ InternalErrorCode["GAME_ROUND_LOG_NOT_FOUND"] = "GAME_ROUND_LOG_NOT_FOUND";
51
+ // Geo Validation errors
52
+ InternalErrorCode["COUNTRY_NOT_PERMITTED"] = "COUNTRY_NOT_PERMITTED";
53
+ InternalErrorCode["GEO_VALIDATION_SERVICE_UNAVAILABLE"] = "GEO_VALIDATION_SERVICE_UNAVAILABLE";
54
+ InternalErrorCode["RESOURCE_NOT_FOUND"] = "RESOURCE_NOT_FOUND";
55
+ // Financial transaction errors
56
+ InternalErrorCode["FINANCIAL_TRANSACTION_NOT_FOUND"] = "FINANCIAL_TRANSACTION_NOT_FOUND";
57
+ //Health check errors
58
+ InternalErrorCode["HEALTH_CHECK_FAILED"] = "HEALTH_CHECK_FAILED";
59
+ //Jackpot errors
60
+ InternalErrorCode["JACKPOT_TYPE_NOT_FOUND"] = "JACKPOT_TYPE_NOT_FOUND";
61
+ InternalErrorCode["JACKPOT_TIER_NOT_FOUND"] = "JACKPOT_TIER_NOT_FOUND";
62
+ InternalErrorCode["JACKPOT_CONFIGURATION_NOT_FOUND"] = "JACKPOT_CONFIGURATION_NOT_FOUND";
63
+ InternalErrorCode["JACKPOT_CONFIGURATION_IS_ACTIVE"] = "JACKPOT_CONFIGURATION_IS_ACTIVE";
64
+ InternalErrorCode["JACKPOT_POOL_CONTRIBUTION_ALREADY_PROCESSED"] = "JACKPOT_POOL_CONTRIBUTION_ALREADY_PROCESSED";
65
+ InternalErrorCode["JACKPOT_TYPE_DOES_NOT_SUPPORT_TIERS"] = "JACKPOT_TYPE_DOES_NOT_SUPPORT_TIERS";
66
+ // RNG and Replay errors
67
+ InternalErrorCode["RNG_SEED_NOT_FOUND"] = "RNG_SEED_NOT_FOUND";
68
+ InternalErrorCode["RNG_SEED_MISMATCH"] = "RNG_SEED_MISMATCH";
69
+ InternalErrorCode["MASTER_HASH_INVALID"] = "MASTER_HASH_INVALID";
70
+ InternalErrorCode["REPLAY_OUTCOME_MISMATCH"] = "REPLAY_OUTCOME_MISMATCH";
71
+ // Concurrency
72
+ InternalErrorCode["CONCURRENT_MODIFICATION"] = "CONCURRENT_MODIFICATION";
73
+ InternalErrorCode["ACCOUNT_LOCKED"] = "ACCOUNT_LOCKED";
74
+ InternalErrorCode["DAILY_LIMIT_EXCEEDED"] = "DAILY_LIMIT_EXCEEDED";
75
+ InternalErrorCode["INVALID_AMOUNT"] = "INVALID_AMOUNT";
76
+ InternalErrorCode["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
77
+ })(InternalErrorCode || (InternalErrorCode = {}));
@@ -0,0 +1,25 @@
1
+ // Logger
2
+ export { Logger } from './logger/logger';
3
+ export { LoggerModule } from './logger/logger.module';
4
+ export { LoggingMiddleware } from './logger/logging.middleware';
5
+ // Error Handling
6
+ export { DomainException } from './error-handling/domain.exception';
7
+ export { InternalErrorCode } from './error-handling/internal-error-code';
8
+ export { ErrorCodeMapper } from './error-handling/error-code-mapper';
9
+ export { ExceptionsFilter } from './error-handling/all-exceptions.filter';
10
+ // Secrets Provider
11
+ export { SECRETS_PROVIDER } from './secrets-provider/secrets-provider';
12
+ export { SecretsModule } from './secrets-provider/secrets-provider.module';
13
+ export { LocalSecretsProvider } from './secrets-provider/secrets-provider.local';
14
+ export { AwsSecretsProvider } from './secrets-provider/secrets-provider.aws';
15
+ // Retry
16
+ export { RetryPolicy } from './retry/retry-policy';
17
+ export { RetryPolicies, HTTP_RETRYABLE_ERRORS } from './retry/retry-policies';
18
+ // Metrics
19
+ export { METRICS_PORT } from './metrics/metrics.port';
20
+ export { PrometheusService } from './metrics/prometheus.service';
21
+ export { MetricsModule } from './metrics/metrics.module';
22
+ export { DatabaseMetricsService } from './metrics/database-metrics.service';
23
+ export { toMinorUnits, getEventCountBucket, getStreamVersionBucket, sanitizeRoute, } from './metrics/helpers/metrics.helpers';
24
+ // API Docs
25
+ export { setupDocumentation } from './api-docs/setup-documentation';