@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.
- package/dist/bootstrap/index.d.ts +15 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +156 -0
- package/dist/common/api-docs/setup-documentation.d.ts +3 -0
- package/dist/common/api-docs/setup-documentation.d.ts.map +1 -0
- package/dist/common/api-docs/setup-documentation.js +27 -0
- package/dist/common/application-bootstrap-options.interface.d.ts +4 -0
- package/dist/common/application-bootstrap-options.interface.d.ts.map +1 -0
- package/dist/common/application-bootstrap-options.interface.js +2 -0
- package/dist/common/error-handling/all-exceptions.filter.d.ts +22 -0
- package/dist/common/error-handling/all-exceptions.filter.d.ts.map +1 -0
- package/dist/common/error-handling/all-exceptions.filter.js +131 -0
- package/dist/common/error-handling/domain.exception.d.ts +8 -0
- package/dist/common/error-handling/domain.exception.d.ts.map +1 -0
- package/dist/common/error-handling/domain.exception.js +14 -0
- package/dist/common/error-handling/error-code-mapper.d.ts +6 -0
- package/dist/common/error-handling/error-code-mapper.d.ts.map +1 -0
- package/dist/common/error-handling/error-code-mapper.js +93 -0
- package/dist/common/error-handling/internal-error-code.d.ts +67 -0
- package/dist/common/error-handling/internal-error-code.d.ts.map +1 -0
- package/dist/common/error-handling/internal-error-code.js +80 -0
- package/dist/common/index.d.ts +21 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +51 -0
- package/dist/common/logger/logger.d.ts +24 -0
- package/dist/common/logger/logger.d.ts.map +1 -0
- package/dist/common/logger/logger.js +137 -0
- package/dist/common/logger/logger.module.d.ts +3 -0
- package/dist/common/logger/logger.module.d.ts.map +1 -0
- package/dist/common/logger/logger.module.js +19 -0
- package/dist/common/logger/logging.middleware.d.ts +8 -0
- package/dist/common/logger/logging.middleware.d.ts.map +1 -0
- package/dist/common/logger/logging.middleware.js +44 -0
- package/dist/common/metrics/database-metrics.service.d.ts +8 -0
- package/dist/common/metrics/database-metrics.service.d.ts.map +1 -0
- package/dist/common/metrics/database-metrics.service.js +39 -0
- package/dist/common/metrics/helpers/metrics.helpers.d.ts +5 -0
- package/dist/common/metrics/helpers/metrics.helpers.d.ts.map +1 -0
- package/dist/common/metrics/helpers/metrics.helpers.js +38 -0
- package/dist/common/metrics/metrics.module.d.ts +3 -0
- package/dist/common/metrics/metrics.module.d.ts.map +1 -0
- package/dist/common/metrics/metrics.module.js +207 -0
- package/dist/common/metrics/metrics.port.d.ts +22 -0
- package/dist/common/metrics/metrics.port.d.ts.map +1 -0
- package/dist/common/metrics/metrics.port.js +4 -0
- package/dist/common/metrics/prometheus.service.d.ts +25 -0
- package/dist/common/metrics/prometheus.service.d.ts.map +1 -0
- package/dist/common/metrics/prometheus.service.js +105 -0
- package/dist/common/retry/retry-policies.d.ts +8 -0
- package/dist/common/retry/retry-policies.d.ts.map +1 -0
- package/dist/common/retry/retry-policies.js +43 -0
- package/dist/common/retry/retry-policy.d.ts +25 -0
- package/dist/common/retry/retry-policy.d.ts.map +1 -0
- package/dist/common/retry/retry-policy.js +65 -0
- package/dist/common/secrets-provider/secrets-provider.aws.d.ts +13 -0
- package/dist/common/secrets-provider/secrets-provider.aws.d.ts.map +1 -0
- package/dist/common/secrets-provider/secrets-provider.aws.js +72 -0
- package/dist/common/secrets-provider/secrets-provider.d.ts +5 -0
- package/dist/common/secrets-provider/secrets-provider.d.ts.map +1 -0
- package/dist/common/secrets-provider/secrets-provider.js +4 -0
- package/dist/common/secrets-provider/secrets-provider.local.d.ts +8 -0
- package/dist/common/secrets-provider/secrets-provider.local.d.ts.map +1 -0
- package/dist/common/secrets-provider/secrets-provider.local.js +75 -0
- package/dist/common/secrets-provider/secrets-provider.module.d.ts +5 -0
- package/dist/common/secrets-provider/secrets-provider.module.d.ts.map +1 -0
- package/dist/common/secrets-provider/secrets-provider.module.js +47 -0
- package/dist/esm/bootstrap/index.js +120 -0
- package/dist/esm/common/api-docs/setup-documentation.js +23 -0
- package/dist/esm/common/application-bootstrap-options.interface.js +1 -0
- package/dist/esm/common/error-handling/all-exceptions.filter.js +128 -0
- package/dist/esm/common/error-handling/domain.exception.js +10 -0
- package/dist/esm/common/error-handling/error-code-mapper.js +89 -0
- package/dist/esm/common/error-handling/internal-error-code.js +77 -0
- package/dist/esm/common/index.js +25 -0
- package/dist/esm/common/logger/logger.js +133 -0
- package/dist/esm/common/logger/logger.module.js +16 -0
- package/dist/esm/common/logger/logging.middleware.js +41 -0
- package/dist/esm/common/metrics/database-metrics.service.js +36 -0
- package/dist/esm/common/metrics/helpers/metrics.helpers.js +32 -0
- package/dist/esm/common/metrics/metrics.module.js +204 -0
- package/dist/esm/common/metrics/metrics.port.js +1 -0
- package/dist/esm/common/metrics/prometheus.service.js +102 -0
- package/dist/esm/common/retry/retry-policies.js +39 -0
- package/dist/esm/common/retry/retry-policy.js +61 -0
- package/dist/esm/common/secrets-provider/secrets-provider.aws.js +69 -0
- package/dist/esm/common/secrets-provider/secrets-provider.js +1 -0
- package/dist/esm/common/secrets-provider/secrets-provider.local.js +39 -0
- package/dist/esm/common/secrets-provider/secrets-provider.module.js +44 -0
- package/dist/esm/generated/game-engine-registry_pb.js +28 -0
- package/dist/esm/generated/game-engine_pb.js +57 -0
- package/dist/esm/grpc/connect-router.middleware.js +16 -0
- package/dist/esm/grpc/game-engine.grpc.in-adapter.js +109 -0
- package/dist/esm/grpc/index.js +2 -0
- package/dist/esm/health/application/ports/in/health-in.port.js +1 -0
- package/dist/esm/health/application/ports/out/database-health.out-port.js +1 -0
- package/dist/esm/health/application/ports/out/shutdown.out-port.js +1 -0
- package/dist/esm/health/application/ports/out/system-health.out-port.js +1 -0
- package/dist/esm/health/application/services/health.service.js +81 -0
- package/dist/esm/health/domain/health.js +7 -0
- package/dist/esm/health/health.module.js +65 -0
- package/dist/esm/health/index.js +15 -0
- package/dist/esm/health/infrastructure/adapters/in/health.http.in-adapter.js +96 -0
- package/dist/esm/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.js +45 -0
- package/dist/esm/health/infrastructure/adapters/out/system/system-health.out-adapter.js +43 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/registration/adapters/game-engine-registry.grpc.out-adapter.js +59 -0
- package/dist/esm/registration/index.js +3 -0
- package/dist/esm/registration/ports/game-engine-registry.out-port.js +1 -0
- package/dist/esm/registration/services/game-engine-auto-register.service.js +78 -0
- package/dist/esm/types.js +8 -0
- package/dist/generated/game-engine-registry_pb.d.ts +76 -0
- package/dist/generated/game-engine-registry_pb.d.ts.map +1 -0
- package/dist/generated/game-engine-registry_pb.js +31 -0
- package/dist/generated/game-engine_pb.d.ts +171 -0
- package/dist/generated/game-engine_pb.d.ts.map +1 -0
- package/dist/generated/game-engine_pb.js +60 -0
- package/dist/grpc/connect-router.middleware.d.ts +7 -0
- package/dist/grpc/connect-router.middleware.d.ts.map +1 -0
- package/dist/grpc/connect-router.middleware.js +19 -0
- package/dist/grpc/game-engine.grpc.in-adapter.d.ts +21 -0
- package/dist/grpc/game-engine.grpc.in-adapter.d.ts.map +1 -0
- package/dist/grpc/game-engine.grpc.in-adapter.js +112 -0
- package/dist/grpc/index.d.ts +3 -0
- package/dist/grpc/index.d.ts.map +1 -0
- package/dist/grpc/index.js +7 -0
- package/dist/health/application/ports/in/health-in.port.d.ts +7 -0
- package/dist/health/application/ports/in/health-in.port.d.ts.map +1 -0
- package/dist/health/application/ports/in/health-in.port.js +4 -0
- package/dist/health/application/ports/out/database-health.out-port.d.ts +6 -0
- package/dist/health/application/ports/out/database-health.out-port.d.ts.map +1 -0
- package/dist/health/application/ports/out/database-health.out-port.js +4 -0
- package/dist/health/application/ports/out/shutdown.out-port.d.ts +6 -0
- package/dist/health/application/ports/out/shutdown.out-port.d.ts.map +1 -0
- package/dist/health/application/ports/out/shutdown.out-port.js +4 -0
- package/dist/health/application/ports/out/system-health.out-port.d.ts +7 -0
- package/dist/health/application/ports/out/system-health.out-port.d.ts.map +1 -0
- package/dist/health/application/ports/out/system-health.out-port.js +4 -0
- package/dist/health/application/services/health.service.d.ts +13 -0
- package/dist/health/application/services/health.service.d.ts.map +1 -0
- package/dist/health/application/services/health.service.js +84 -0
- package/dist/health/domain/health.d.ts +15 -0
- package/dist/health/domain/health.d.ts.map +1 -0
- package/dist/health/domain/health.js +11 -0
- package/dist/health/health.module.d.ts +10 -0
- package/dist/health/health.module.d.ts.map +1 -0
- package/dist/health/health.module.js +68 -0
- package/dist/health/index.d.ts +11 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +28 -0
- package/dist/health/infrastructure/adapters/in/health.http.in-adapter.d.ts +16 -0
- package/dist/health/infrastructure/adapters/in/health.http.in-adapter.d.ts.map +1 -0
- package/dist/health/infrastructure/adapters/in/health.http.in-adapter.js +99 -0
- package/dist/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.d.ts +13 -0
- package/dist/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.d.ts.map +1 -0
- package/dist/health/infrastructure/adapters/out/shutdown/shutdown.out-adapter.js +48 -0
- package/dist/health/infrastructure/adapters/out/system/system-health.out-adapter.d.ts +12 -0
- package/dist/health/infrastructure/adapters/out/system/system-health.out-adapter.d.ts.map +1 -0
- package/dist/health/infrastructure/adapters/out/system/system-health.out-adapter.js +46 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/registration/adapters/game-engine-registry.grpc.out-adapter.d.ts +12 -0
- package/dist/registration/adapters/game-engine-registry.grpc.out-adapter.d.ts.map +1 -0
- package/dist/registration/adapters/game-engine-registry.grpc.out-adapter.js +62 -0
- package/dist/registration/index.d.ts +4 -0
- package/dist/registration/index.d.ts.map +1 -0
- package/dist/registration/index.js +9 -0
- package/dist/registration/ports/game-engine-registry.out-port.d.ts +9 -0
- package/dist/registration/ports/game-engine-registry.out-port.d.ts.map +1 -0
- package/dist/registration/ports/game-engine-registry.out-port.js +4 -0
- package/dist/registration/services/game-engine-auto-register.service.d.ts +14 -0
- package/dist/registration/services/game-engine-auto-register.service.d.ts.map +1 -0
- package/dist/registration/services/game-engine-auto-register.service.js +81 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/package.json +159 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
export interface GameEngineAppOptions {
|
|
3
|
+
serviceName: string;
|
|
4
|
+
appModule: Type<any>;
|
|
5
|
+
bootstrapOptions?: {
|
|
6
|
+
driver: 'database' | 'in-memory';
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates and bootstraps a game engine NestJS application with
|
|
11
|
+
* standard configuration: CORS, validation pipes, exception filters,
|
|
12
|
+
* Swagger docs, Connect RPC gRPC server, and graceful shutdown.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createGameEngineApp(options: GameEngineAppOptions): Promise<import("@nestjs/common").INestApplication<any>>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsD,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAK1F,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,gBAAgB,CAAC,EAAE;QAAE,MAAM,EAAE,UAAU,GAAG,WAAW,CAAA;KAAE,CAAC;CACzD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,2DAwHtE"}
|
|
@@ -0,0 +1,156 @@
|
|
|
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 __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createGameEngineApp = createGameEngineApp;
|
|
37
|
+
const logger_1 = require("../common/logger/logger");
|
|
38
|
+
const all_exceptions_filter_1 = require("../common/error-handling/all-exceptions.filter");
|
|
39
|
+
const internal_error_code_1 = require("../common/error-handling/internal-error-code");
|
|
40
|
+
const setup_documentation_1 = require("../common/api-docs/setup-documentation");
|
|
41
|
+
const shutdown_out_port_1 = require("../health/application/ports/out/shutdown.out-port");
|
|
42
|
+
const game_engine_grpc_in_adapter_1 = require("../grpc/game-engine.grpc.in-adapter");
|
|
43
|
+
const connect_router_middleware_1 = require("../grpc/connect-router.middleware");
|
|
44
|
+
const common_1 = require("@nestjs/common");
|
|
45
|
+
const config_1 = require("@nestjs/config");
|
|
46
|
+
const core_1 = require("@nestjs/core");
|
|
47
|
+
const http2 = __importStar(require("http2"));
|
|
48
|
+
/**
|
|
49
|
+
* Creates and bootstraps a game engine NestJS application with
|
|
50
|
+
* standard configuration: CORS, validation pipes, exception filters,
|
|
51
|
+
* Swagger docs, Connect RPC gRPC server, and graceful shutdown.
|
|
52
|
+
*/
|
|
53
|
+
async function createGameEngineApp(options) {
|
|
54
|
+
const { serviceName, appModule, bootstrapOptions } = options;
|
|
55
|
+
const logger = new logger_1.Logger(serviceName);
|
|
56
|
+
const moduleArg = bootstrapOptions
|
|
57
|
+
? appModule.register
|
|
58
|
+
? appModule.register(bootstrapOptions)
|
|
59
|
+
: appModule
|
|
60
|
+
: appModule;
|
|
61
|
+
const app = await core_1.NestFactory.create(moduleArg, {
|
|
62
|
+
logger: logger,
|
|
63
|
+
});
|
|
64
|
+
app.enableCors({ origin: true });
|
|
65
|
+
const configService = app.get(config_1.ConfigService);
|
|
66
|
+
const shutdownService = app.get(shutdown_out_port_1.SHUTDOWN_OUT_PORT);
|
|
67
|
+
let isShuttingDown = false;
|
|
68
|
+
const handleFatalError = async (errorType, error) => {
|
|
69
|
+
logger.error(`${errorType}:`, {
|
|
70
|
+
error: error.message,
|
|
71
|
+
stack: error.stack,
|
|
72
|
+
});
|
|
73
|
+
if (isShuttingDown) {
|
|
74
|
+
logger.warn('Shutdown already in progress, ignoring additional error');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
isShuttingDown = true;
|
|
78
|
+
try {
|
|
79
|
+
logger.warn(`Initiating graceful shutdown due to ${errorType}...`);
|
|
80
|
+
await shutdownService.startGracefulShutdown();
|
|
81
|
+
logger.log('Graceful shutdown completed, exiting process');
|
|
82
|
+
}
|
|
83
|
+
catch (shutdownError) {
|
|
84
|
+
logger.error('Error during graceful shutdown:', shutdownError);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
process.on('uncaughtException', (error) => {
|
|
91
|
+
logger.error('Uncaught Exception:', {
|
|
92
|
+
error: error.message,
|
|
93
|
+
stack: error.stack,
|
|
94
|
+
});
|
|
95
|
+
void handleFatalError('uncaughtException', error);
|
|
96
|
+
});
|
|
97
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
98
|
+
logger.error('Unhandled Rejection:', {
|
|
99
|
+
reason: reason.message,
|
|
100
|
+
stack: reason.stack,
|
|
101
|
+
promise,
|
|
102
|
+
});
|
|
103
|
+
void handleFatalError('unhandledRejection', reason);
|
|
104
|
+
});
|
|
105
|
+
app.setGlobalPrefix('api', {
|
|
106
|
+
exclude: [
|
|
107
|
+
{ path: 'health', method: common_1.RequestMethod.GET },
|
|
108
|
+
{ path: 'ready', method: common_1.RequestMethod.GET },
|
|
109
|
+
{ path: 'metrics', method: common_1.RequestMethod.GET },
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
app.useGlobalPipes(new common_1.ValidationPipe({
|
|
113
|
+
whitelist: true,
|
|
114
|
+
forbidNonWhitelisted: true,
|
|
115
|
+
transform: true,
|
|
116
|
+
exceptionFactory: errors => {
|
|
117
|
+
const messages = errors.map(error => Object.values(error.constraints || {}).join(', '));
|
|
118
|
+
return new common_1.BadRequestException({
|
|
119
|
+
statusCode: 400,
|
|
120
|
+
internalCode: internal_error_code_1.InternalErrorCode.VALIDATION_ERROR,
|
|
121
|
+
message: messages,
|
|
122
|
+
timestamp: new Date().toISOString(),
|
|
123
|
+
path: '/api',
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
}));
|
|
127
|
+
app.useGlobalFilters(app.get(all_exceptions_filter_1.ExceptionsFilter));
|
|
128
|
+
const PORT = configService.get('PORT') || 3000;
|
|
129
|
+
await (0, setup_documentation_1.setupDocumentation)(app, PORT, serviceName);
|
|
130
|
+
// Setup Connect RPC server
|
|
131
|
+
const gameEngineAdapter = app.get(game_engine_grpc_in_adapter_1.GameEngineGrpcInAdapter);
|
|
132
|
+
const connectRouter = (0, connect_router_middleware_1.createConnectRouter)(gameEngineAdapter);
|
|
133
|
+
// Mount Connect router on /connect path
|
|
134
|
+
app.use('/connect', connectRouter);
|
|
135
|
+
app.enableShutdownHooks(['SIGTERM', 'SIGINT']);
|
|
136
|
+
// Start separate h2c (HTTP/2 cleartext) server for Connect RPC
|
|
137
|
+
const GRPC_PORT = configService.get('GRPC_PORT', 50051);
|
|
138
|
+
const h2cServer = http2.createServer({}, connectRouter);
|
|
139
|
+
h2cServer.on('error', (err) => {
|
|
140
|
+
logger.error('h2c gRPC server error:', err);
|
|
141
|
+
});
|
|
142
|
+
h2cServer.listen(GRPC_PORT, '0.0.0.0', () => {
|
|
143
|
+
logger.log(`Connect RPC (h2c) is available on: http://localhost:${GRPC_PORT}`);
|
|
144
|
+
});
|
|
145
|
+
// Close h2c server during graceful shutdown
|
|
146
|
+
const closeH2c = () => {
|
|
147
|
+
h2cServer.close(() => {
|
|
148
|
+
logger.log('h2c gRPC server closed');
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
process.on('SIGTERM', closeH2c);
|
|
152
|
+
process.on('SIGINT', closeH2c);
|
|
153
|
+
await app.listen(PORT, '0.0.0.0');
|
|
154
|
+
logger.log(`Application is running on: http://localhost:${PORT}`);
|
|
155
|
+
return app;
|
|
156
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-documentation.d.ts","sourceRoot":"","sources":["../../../src/common/api-docs/setup-documentation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMlD,eAAO,MAAM,kBAAkB,GAC7B,KAAK,gBAAgB,CAAC,GAAG,CAAC,EAC1B,MAAM,MAAM,EACZ,cAAc,MAAM,kBAqBrB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupDocumentation = void 0;
|
|
4
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
+
const logger_1 = require("../logger/logger");
|
|
6
|
+
const logger = new logger_1.Logger('ApiDocs');
|
|
7
|
+
const setupDocumentation = async (app, port, serviceName) => {
|
|
8
|
+
const config = new swagger_1.DocumentBuilder()
|
|
9
|
+
.setTitle(serviceName ? `${serviceName} API` : 'Game Engine API')
|
|
10
|
+
.setDescription('API documentation')
|
|
11
|
+
.setOpenAPIVersion('3.0.0')
|
|
12
|
+
.build();
|
|
13
|
+
const document = swagger_1.SwaggerModule.createDocument(app, config);
|
|
14
|
+
swagger_1.SwaggerModule.setup('docs', app, document, {
|
|
15
|
+
jsonDocumentUrl: 'docs/json',
|
|
16
|
+
yamlDocumentUrl: 'docs/yaml',
|
|
17
|
+
swaggerOptions: {
|
|
18
|
+
tagsSorter: 'alpha',
|
|
19
|
+
operationsSorter: 'alpha',
|
|
20
|
+
docExpansion: 'list',
|
|
21
|
+
filter: true,
|
|
22
|
+
showRequestHeaders: true,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
logger.log(`Documentation is available on: http://localhost:${port}/docs`);
|
|
26
|
+
};
|
|
27
|
+
exports.setupDocumentation = setupDocumentation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-bootstrap-options.interface.d.ts","sourceRoot":"","sources":["../../src/common/application-bootstrap-options.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;CAClC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MetricsPort } from '../metrics/metrics.port';
|
|
2
|
+
import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
3
|
+
export interface ErrorResponse {
|
|
4
|
+
statusCode: number;
|
|
5
|
+
internalCode: string;
|
|
6
|
+
message: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ExceptionsFilter implements ExceptionFilter {
|
|
11
|
+
private readonly metricsPort;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
constructor(metricsPort: MetricsPort);
|
|
14
|
+
catch(exception: unknown, host: ArgumentsHost): void;
|
|
15
|
+
private buildErrorResponse;
|
|
16
|
+
private handleDomainException;
|
|
17
|
+
private handleHttpException;
|
|
18
|
+
private handleGenericError;
|
|
19
|
+
private handleUnknownError;
|
|
20
|
+
private buildResponsePayload;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=all-exceptions.filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-exceptions.filter.d.ts","sourceRoot":"","sources":["../../../src/common/error-handling/all-exceptions.filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,aAAa,EAEb,eAAe,EAIhB,MAAM,gBAAgB,CAAC;AAOxB,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBACa,gBAAiB,YAAW,eAAe;IAKpD,OAAO,CAAC,QAAQ,CAAC,WAAW;IAJ9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAIb,WAAW,EAAE,WAAW;IAK3C,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa;IAS7C,OAAO,CAAC,kBAAkB;IAgB1B,OAAO,CAAC,qBAAqB;IAqB7B,OAAO,CAAC,mBAAmB;IAmD3B,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,oBAAoB;CAmB7B"}
|
|
@@ -0,0 +1,131 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var ExceptionsFilter_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ExceptionsFilter = void 0;
|
|
17
|
+
const logger_1 = require("../logger/logger");
|
|
18
|
+
const metrics_port_1 = require("../metrics/metrics.port");
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
const domain_exception_1 = require("./domain.exception");
|
|
21
|
+
const error_code_mapper_1 = require("./error-code-mapper");
|
|
22
|
+
const internal_error_code_1 = require("./internal-error-code");
|
|
23
|
+
let ExceptionsFilter = ExceptionsFilter_1 = class ExceptionsFilter {
|
|
24
|
+
constructor(metricsPort) {
|
|
25
|
+
this.metricsPort = metricsPort;
|
|
26
|
+
this.logger = new logger_1.Logger(ExceptionsFilter_1.name);
|
|
27
|
+
}
|
|
28
|
+
catch(exception, host) {
|
|
29
|
+
const ctx = host.switchToHttp();
|
|
30
|
+
const response = ctx.getResponse();
|
|
31
|
+
const request = ctx.getRequest();
|
|
32
|
+
const errorResponse = this.buildErrorResponse(exception, request);
|
|
33
|
+
response.status(errorResponse.statusCode).json(errorResponse);
|
|
34
|
+
}
|
|
35
|
+
buildErrorResponse(exception, request) {
|
|
36
|
+
if (exception instanceof domain_exception_1.DomainException) {
|
|
37
|
+
return this.handleDomainException(exception, request);
|
|
38
|
+
}
|
|
39
|
+
if (exception instanceof common_1.HttpException) {
|
|
40
|
+
return this.handleHttpException(exception, request);
|
|
41
|
+
}
|
|
42
|
+
if (exception instanceof Error) {
|
|
43
|
+
return this.handleGenericError(exception, request);
|
|
44
|
+
}
|
|
45
|
+
return this.handleUnknownError(exception, request);
|
|
46
|
+
}
|
|
47
|
+
handleDomainException(exception, request) {
|
|
48
|
+
const status = error_code_mapper_1.ErrorCodeMapper.mapToHttpStatus(exception.errorCode);
|
|
49
|
+
const level = status >= 500 ? 'error' : 'warn';
|
|
50
|
+
this.logger.log(`DomainException (status: ${status} at ${request.method} ${request.url}): Internal Code ${exception.errorCode} Message: ${exception.message}`, { level });
|
|
51
|
+
if (exception.cause) {
|
|
52
|
+
this.logger.error('Exception cause:', exception.cause);
|
|
53
|
+
}
|
|
54
|
+
return this.buildResponsePayload({
|
|
55
|
+
status,
|
|
56
|
+
internalCode: exception.errorCode,
|
|
57
|
+
message: exception.message,
|
|
58
|
+
path: request.url,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
handleHttpException(exception, request) {
|
|
62
|
+
const status = exception.getStatus();
|
|
63
|
+
const responseData = exception.getResponse();
|
|
64
|
+
// Check if this is a custom validation error response
|
|
65
|
+
if (typeof responseData === 'object' &&
|
|
66
|
+
responseData.internalCode &&
|
|
67
|
+
responseData.statusCode) {
|
|
68
|
+
return responseData;
|
|
69
|
+
}
|
|
70
|
+
let message = 'HTTP Exception';
|
|
71
|
+
if (typeof responseData === 'string') {
|
|
72
|
+
message = responseData;
|
|
73
|
+
}
|
|
74
|
+
else if (typeof responseData === 'object' && responseData.message) {
|
|
75
|
+
message = responseData.message;
|
|
76
|
+
}
|
|
77
|
+
const level = status >= 500 ? 'error' : 'warn';
|
|
78
|
+
this.logger.log(`HttpException (status: ${status} at ${request.method} ${request.url}): ${message}`, { level });
|
|
79
|
+
if (status === 401 || status === 403) {
|
|
80
|
+
const internalCode = status === 401 ? internal_error_code_1.InternalErrorCode.UNAUTHORIZED : internal_error_code_1.InternalErrorCode.FORBIDDEN;
|
|
81
|
+
return this.buildResponsePayload({
|
|
82
|
+
status,
|
|
83
|
+
internalCode,
|
|
84
|
+
message,
|
|
85
|
+
path: request.url,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (status === common_1.HttpStatus.INTERNAL_SERVER_ERROR) {
|
|
89
|
+
this.logger.error('HttpException stack:', exception.stack);
|
|
90
|
+
}
|
|
91
|
+
return this.buildResponsePayload({
|
|
92
|
+
status,
|
|
93
|
+
internalCode: internal_error_code_1.InternalErrorCode.INTERNAL_SERVER_ERROR,
|
|
94
|
+
message,
|
|
95
|
+
path: request.url,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
handleGenericError(exception, request) {
|
|
99
|
+
this.logger.error(`Unhandled Error (status: ${common_1.HttpStatus.INTERNAL_SERVER_ERROR} at ${request.method} ${request.url}): ${exception.stack}`);
|
|
100
|
+
return this.buildResponsePayload({
|
|
101
|
+
status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
102
|
+
internalCode: internal_error_code_1.InternalErrorCode.INTERNAL_SERVER_ERROR,
|
|
103
|
+
message: exception.message,
|
|
104
|
+
path: request.url,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
handleUnknownError(exception, request) {
|
|
108
|
+
this.logger.error(`Unknown error type (status: ${common_1.HttpStatus.INTERNAL_SERVER_ERROR} at ${request.method} ${request.url}): ${String(exception)}`);
|
|
109
|
+
return this.buildResponsePayload({
|
|
110
|
+
status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
111
|
+
internalCode: internal_error_code_1.InternalErrorCode.INTERNAL_SERVER_ERROR,
|
|
112
|
+
message: 'Internal server error',
|
|
113
|
+
path: request.url,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
buildResponsePayload({ status, internalCode, message, path, }) {
|
|
117
|
+
return {
|
|
118
|
+
statusCode: status,
|
|
119
|
+
internalCode,
|
|
120
|
+
message,
|
|
121
|
+
timestamp: new Date().toISOString(),
|
|
122
|
+
path,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.ExceptionsFilter = ExceptionsFilter;
|
|
127
|
+
exports.ExceptionsFilter = ExceptionsFilter = ExceptionsFilter_1 = __decorate([
|
|
128
|
+
(0, common_1.Catch)(),
|
|
129
|
+
__param(0, (0, common_1.Inject)(metrics_port_1.METRICS_PORT)),
|
|
130
|
+
__metadata("design:paramtypes", [Object])
|
|
131
|
+
], ExceptionsFilter);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InternalErrorCode } from './internal-error-code';
|
|
2
|
+
export declare class DomainException extends Error {
|
|
3
|
+
readonly errorCode: InternalErrorCode;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly cause?: unknown | undefined;
|
|
6
|
+
constructor(errorCode: InternalErrorCode, message: string, cause?: unknown | undefined);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=domain.exception.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.exception.d.ts","sourceRoot":"","sources":["../../../src/common/error-handling/domain.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,KAAK;aAEtB,SAAS,EAAE,iBAAiB;aAC5B,OAAO,EAAE,MAAM;aACf,KAAK,CAAC,EAAE,OAAO;gBAFf,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,YAAA;CAMlC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainException = void 0;
|
|
4
|
+
class DomainException extends Error {
|
|
5
|
+
constructor(errorCode, message, cause) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.errorCode = errorCode;
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.cause = cause;
|
|
10
|
+
this.name = 'DomainException';
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DomainException = DomainException;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-code-mapper.d.ts","sourceRoot":"","sources":["../../../src/common/error-handling/error-code-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAa1D,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CA4E5C;IAEF,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM;CAG7D"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorCodeMapper = void 0;
|
|
4
|
+
const internal_error_code_1 = require("./internal-error-code");
|
|
5
|
+
// HTTP status codes
|
|
6
|
+
const HttpStatus = {
|
|
7
|
+
BAD_REQUEST: 400,
|
|
8
|
+
CONFLICT: 409,
|
|
9
|
+
FORBIDDEN: 403,
|
|
10
|
+
NOT_FOUND: 404,
|
|
11
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
12
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
13
|
+
SERVICE_UNAVAILABLE: 503,
|
|
14
|
+
};
|
|
15
|
+
class ErrorCodeMapper {
|
|
16
|
+
static mapToHttpStatus(errorCode) {
|
|
17
|
+
return this.ERROR_CODE_TO_HTTP_MAP[errorCode] || HttpStatus.BAD_REQUEST;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ErrorCodeMapper = ErrorCodeMapper;
|
|
21
|
+
ErrorCodeMapper.ERROR_CODE_TO_HTTP_MAP = {
|
|
22
|
+
[internal_error_code_1.InternalErrorCode.FORBIDDEN]: HttpStatus.FORBIDDEN,
|
|
23
|
+
[internal_error_code_1.InternalErrorCode.INVALID_CURRENCY_CODE]: HttpStatus.BAD_REQUEST,
|
|
24
|
+
[internal_error_code_1.InternalErrorCode.INSUFFICIENT_FUNDS]: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
25
|
+
[internal_error_code_1.InternalErrorCode.INTERNAL_SERVER_ERROR]: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
26
|
+
// Game Catalog errors
|
|
27
|
+
[internal_error_code_1.InternalErrorCode.GAME_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
28
|
+
[internal_error_code_1.InternalErrorCode.GAME_CONFIG_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
29
|
+
[internal_error_code_1.InternalErrorCode.GAME_CONFIG_ALREADY_EXISTS_WITH_SAME_JURISDICTION_AND_RTP]: HttpStatus.BAD_REQUEST,
|
|
30
|
+
[internal_error_code_1.InternalErrorCode.OPERATOR_GAME_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
31
|
+
[internal_error_code_1.InternalErrorCode.OPERATOR_GAME_ALREADY_ENABLED]: HttpStatus.BAD_REQUEST,
|
|
32
|
+
[internal_error_code_1.InternalErrorCode.INVALID_GAME_CONFIG_DATA]: HttpStatus.BAD_REQUEST,
|
|
33
|
+
[internal_error_code_1.InternalErrorCode.INVALID_GAME_UPDATE_DATA]: HttpStatus.BAD_REQUEST,
|
|
34
|
+
[internal_error_code_1.InternalErrorCode.GAME_CODE_ALREADY_EXISTS]: HttpStatus.BAD_REQUEST,
|
|
35
|
+
[internal_error_code_1.InternalErrorCode.GAME_OR_GAME_CONFIG_DISABLED]: HttpStatus.BAD_REQUEST,
|
|
36
|
+
[internal_error_code_1.InternalErrorCode.DEBUG_COMMANDS_DISABLED]: HttpStatus.FORBIDDEN,
|
|
37
|
+
// Game Orchestrator errors
|
|
38
|
+
[internal_error_code_1.InternalErrorCode.INVALID_SESSION]: HttpStatus.BAD_REQUEST,
|
|
39
|
+
[internal_error_code_1.InternalErrorCode.SESSION_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
40
|
+
[internal_error_code_1.InternalErrorCode.SESSION_NOT_ACTIVE]: HttpStatus.BAD_REQUEST,
|
|
41
|
+
[internal_error_code_1.InternalErrorCode.SESSION_MISMATCH]: HttpStatus.BAD_REQUEST,
|
|
42
|
+
[internal_error_code_1.InternalErrorCode.INVALID_STATE_TRANSITION]: HttpStatus.BAD_REQUEST,
|
|
43
|
+
[internal_error_code_1.InternalErrorCode.INVALID_BET_AMOUNT]: HttpStatus.BAD_REQUEST,
|
|
44
|
+
[internal_error_code_1.InternalErrorCode.REALITY_CHECK_IN_PROGRESS]: HttpStatus.BAD_REQUEST,
|
|
45
|
+
[internal_error_code_1.InternalErrorCode.UNKNOWN_COMMAND]: HttpStatus.NOT_FOUND,
|
|
46
|
+
// Operator errors
|
|
47
|
+
[internal_error_code_1.InternalErrorCode.MISSING_OPERATOR_CODE]: HttpStatus.BAD_REQUEST,
|
|
48
|
+
[internal_error_code_1.InternalErrorCode.INVALID_OPERATOR_CODE]: HttpStatus.BAD_REQUEST,
|
|
49
|
+
[internal_error_code_1.InternalErrorCode.OPERATOR_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
50
|
+
[internal_error_code_1.InternalErrorCode.OPERATOR_INACTIVE]: HttpStatus.FORBIDDEN,
|
|
51
|
+
[internal_error_code_1.InternalErrorCode.COUNTRY_CODE_RESTRICTED]: HttpStatus.BAD_REQUEST,
|
|
52
|
+
[internal_error_code_1.InternalErrorCode.UNAUTHORIZED]: HttpStatus.FORBIDDEN,
|
|
53
|
+
[internal_error_code_1.InternalErrorCode.AUTH_VALIDATION_FAILED]: HttpStatus.FORBIDDEN,
|
|
54
|
+
[internal_error_code_1.InternalErrorCode.BALANCE_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
55
|
+
[internal_error_code_1.InternalErrorCode.INVALID_AUTH_DATA]: HttpStatus.BAD_REQUEST,
|
|
56
|
+
[internal_error_code_1.InternalErrorCode.VALIDATION_ERROR]: HttpStatus.BAD_REQUEST,
|
|
57
|
+
[internal_error_code_1.InternalErrorCode.JURISDICTION_CONFIG_ALREADY_EXISTS]: HttpStatus.BAD_REQUEST,
|
|
58
|
+
[internal_error_code_1.InternalErrorCode.JURISDICTION_CONFIG_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
59
|
+
[internal_error_code_1.InternalErrorCode.OPERATOR_JURISDICTION_CONFIG_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
60
|
+
[internal_error_code_1.InternalErrorCode.GAME_ENGINE_ERROR]: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
61
|
+
[internal_error_code_1.InternalErrorCode.DEBIT_FAILED]: HttpStatus.BAD_REQUEST,
|
|
62
|
+
[internal_error_code_1.InternalErrorCode.CREDIT_FAILED]: HttpStatus.BAD_REQUEST,
|
|
63
|
+
[internal_error_code_1.InternalErrorCode.GAME_ROUND_LOG_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
64
|
+
// Geo Validation errors
|
|
65
|
+
[internal_error_code_1.InternalErrorCode.COUNTRY_NOT_PERMITTED]: HttpStatus.FORBIDDEN,
|
|
66
|
+
[internal_error_code_1.InternalErrorCode.GEO_VALIDATION_SERVICE_UNAVAILABLE]: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
67
|
+
[internal_error_code_1.InternalErrorCode.RESOURCE_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
68
|
+
[internal_error_code_1.InternalErrorCode.FINANCIAL_TRANSACTION_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
69
|
+
[internal_error_code_1.InternalErrorCode.SESSION_TERMINATED]: HttpStatus.BAD_REQUEST,
|
|
70
|
+
[internal_error_code_1.InternalErrorCode.SESSION_CANNOT_BE_TERMINATED]: HttpStatus.BAD_REQUEST,
|
|
71
|
+
[internal_error_code_1.InternalErrorCode.SESSION_AUTO_RESOLVE_FAILED]: HttpStatus.BAD_REQUEST,
|
|
72
|
+
[internal_error_code_1.InternalErrorCode.SESSION_ALREADY_EXISTS]: HttpStatus.BAD_REQUEST,
|
|
73
|
+
[internal_error_code_1.InternalErrorCode.INCOMPATIBLE_GAMEPLAY_CONFIG]: HttpStatus.BAD_REQUEST,
|
|
74
|
+
// Health check errors
|
|
75
|
+
[internal_error_code_1.InternalErrorCode.HEALTH_CHECK_FAILED]: HttpStatus.SERVICE_UNAVAILABLE,
|
|
76
|
+
//Jackpot errors
|
|
77
|
+
[internal_error_code_1.InternalErrorCode.JACKPOT_TYPE_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
78
|
+
[internal_error_code_1.InternalErrorCode.JACKPOT_TIER_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
79
|
+
[internal_error_code_1.InternalErrorCode.JACKPOT_CONFIGURATION_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
80
|
+
[internal_error_code_1.InternalErrorCode.JACKPOT_CONFIGURATION_IS_ACTIVE]: HttpStatus.BAD_REQUEST,
|
|
81
|
+
// RNG and Replay errors
|
|
82
|
+
[internal_error_code_1.InternalErrorCode.RNG_SEED_NOT_FOUND]: HttpStatus.NOT_FOUND,
|
|
83
|
+
[internal_error_code_1.InternalErrorCode.RNG_SEED_MISMATCH]: HttpStatus.BAD_REQUEST,
|
|
84
|
+
[internal_error_code_1.InternalErrorCode.MASTER_HASH_INVALID]: HttpStatus.BAD_REQUEST,
|
|
85
|
+
[internal_error_code_1.InternalErrorCode.REPLAY_OUTCOME_MISMATCH]: HttpStatus.BAD_REQUEST,
|
|
86
|
+
[internal_error_code_1.InternalErrorCode.JACKPOT_POOL_CONTRIBUTION_ALREADY_PROCESSED]: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
87
|
+
[internal_error_code_1.InternalErrorCode.JACKPOT_TYPE_DOES_NOT_SUPPORT_TIERS]: HttpStatus.BAD_REQUEST,
|
|
88
|
+
[internal_error_code_1.InternalErrorCode.CONCURRENT_MODIFICATION]: HttpStatus.CONFLICT,
|
|
89
|
+
[internal_error_code_1.InternalErrorCode.ACCOUNT_LOCKED]: HttpStatus.FORBIDDEN,
|
|
90
|
+
[internal_error_code_1.InternalErrorCode.DAILY_LIMIT_EXCEEDED]: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
91
|
+
[internal_error_code_1.InternalErrorCode.INVALID_AMOUNT]: HttpStatus.BAD_REQUEST,
|
|
92
|
+
[internal_error_code_1.InternalErrorCode.SERVICE_UNAVAILABLE]: HttpStatus.SERVICE_UNAVAILABLE,
|
|
93
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare enum InternalErrorCode {
|
|
2
|
+
FORBIDDEN = "FORBIDDEN",
|
|
3
|
+
INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR",
|
|
4
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
5
|
+
INVALID_CURRENCY_CODE = "INVALID_CURRENCY_CODE",
|
|
6
|
+
GAME_NOT_FOUND = "GAME_NOT_FOUND",
|
|
7
|
+
GAME_CONFIG_NOT_FOUND = "GAME_CONFIG_NOT_FOUND",
|
|
8
|
+
GAME_CONFIG_ALREADY_EXISTS_WITH_SAME_JURISDICTION_AND_RTP = "GAME_CONFIG_ALREADY_EXISTS_WITH_SAME_JURISDICTION_AND_RTP",
|
|
9
|
+
OPERATOR_GAME_NOT_FOUND = "OPERATOR_GAME_NOT_FOUND",
|
|
10
|
+
OPERATOR_GAME_ALREADY_ENABLED = "OPERATOR_GAME_ALREADY_ENABLED",
|
|
11
|
+
INVALID_GAME_CONFIG_DATA = "INVALID_GAME_CONFIG_DATA",
|
|
12
|
+
INVALID_GAME_UPDATE_DATA = "INVALID_GAME_UPDATE_DATA",
|
|
13
|
+
GAME_CODE_ALREADY_EXISTS = "GAME_CODE_ALREADY_EXISTS",
|
|
14
|
+
GAME_ENGINE_ERROR = "GAME_ENGINE_ERROR",
|
|
15
|
+
GAME_OR_GAME_CONFIG_DISABLED = "GAME_OR_GAME_CONFIG_DISABLED",
|
|
16
|
+
DEBUG_COMMANDS_DISABLED = "DEBUG_COMMANDS_DISABLED",
|
|
17
|
+
INVALID_SESSION = "INVALID_SESSION",
|
|
18
|
+
SESSION_NOT_FOUND = "SESSION_NOT_FOUND",
|
|
19
|
+
SESSION_NOT_ACTIVE = "SESSION_NOT_ACTIVE",
|
|
20
|
+
SESSION_MISMATCH = "SESSION_MISMATCH",
|
|
21
|
+
INVALID_STATE_TRANSITION = "INVALID_STATE_TRANSITION",
|
|
22
|
+
INVALID_BET_AMOUNT = "INVALID_BET_AMOUNT",
|
|
23
|
+
REALITY_CHECK_IN_PROGRESS = "REALITY_CHECK_IN_PROGRESS",
|
|
24
|
+
SESSION_TERMINATED = "SESSION_TERMINATED",
|
|
25
|
+
SESSION_CANNOT_BE_TERMINATED = "SESSION_CANNOT_BE_TERMINATED",
|
|
26
|
+
SESSION_AUTO_RESOLVE_FAILED = "SESSION_AUTO_RESOLVE_FAILED",
|
|
27
|
+
SESSION_ALREADY_EXISTS = "SESSION_ALREADY_EXISTS",
|
|
28
|
+
INCOMPATIBLE_GAMEPLAY_CONFIG = "INCOMPATIBLE_GAMEPLAY_CONFIG",
|
|
29
|
+
UNKNOWN_COMMAND = "UNKNOWN_COMMAND",
|
|
30
|
+
MISSING_OPERATOR_CODE = "MISSING_OPERATOR_CODE",
|
|
31
|
+
INVALID_OPERATOR_CODE = "INVALID_OPERATOR_CODE",
|
|
32
|
+
OPERATOR_NOT_FOUND = "OPERATOR_NOT_FOUND",
|
|
33
|
+
OPERATOR_INACTIVE = "OPERATOR_INACTIVE",
|
|
34
|
+
COUNTRY_CODE_RESTRICTED = "COUNTRY_CODE_RESTRICTED",
|
|
35
|
+
UNAUTHORIZED = "UNAUTHORIZED",
|
|
36
|
+
AUTH_VALIDATION_FAILED = "AUTH_VALIDATION_FAILED",
|
|
37
|
+
BALANCE_NOT_FOUND = "BALANCE_NOT_FOUND",
|
|
38
|
+
DEBIT_FAILED = "DEBIT_FAILED",
|
|
39
|
+
CREDIT_FAILED = "CREDIT_FAILED",
|
|
40
|
+
INVALID_AUTH_DATA = "INVALID_AUTH_DATA",
|
|
41
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
42
|
+
JURISDICTION_CONFIG_ALREADY_EXISTS = "JURISDICTION_CONFIG_ALREADY_EXISTS",
|
|
43
|
+
JURISDICTION_CONFIG_NOT_FOUND = "JURISDICTION_CONFIG_NOT_FOUND",
|
|
44
|
+
OPERATOR_JURISDICTION_CONFIG_NOT_FOUND = "OPERATOR_JURISDICTION_CONFIG_NOT_FOUND",
|
|
45
|
+
GAME_ROUND_LOG_NOT_FOUND = "GAME_ROUND_LOG_NOT_FOUND",
|
|
46
|
+
COUNTRY_NOT_PERMITTED = "COUNTRY_NOT_PERMITTED",
|
|
47
|
+
GEO_VALIDATION_SERVICE_UNAVAILABLE = "GEO_VALIDATION_SERVICE_UNAVAILABLE",
|
|
48
|
+
RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND",
|
|
49
|
+
FINANCIAL_TRANSACTION_NOT_FOUND = "FINANCIAL_TRANSACTION_NOT_FOUND",
|
|
50
|
+
HEALTH_CHECK_FAILED = "HEALTH_CHECK_FAILED",
|
|
51
|
+
JACKPOT_TYPE_NOT_FOUND = "JACKPOT_TYPE_NOT_FOUND",
|
|
52
|
+
JACKPOT_TIER_NOT_FOUND = "JACKPOT_TIER_NOT_FOUND",
|
|
53
|
+
JACKPOT_CONFIGURATION_NOT_FOUND = "JACKPOT_CONFIGURATION_NOT_FOUND",
|
|
54
|
+
JACKPOT_CONFIGURATION_IS_ACTIVE = "JACKPOT_CONFIGURATION_IS_ACTIVE",
|
|
55
|
+
JACKPOT_POOL_CONTRIBUTION_ALREADY_PROCESSED = "JACKPOT_POOL_CONTRIBUTION_ALREADY_PROCESSED",
|
|
56
|
+
JACKPOT_TYPE_DOES_NOT_SUPPORT_TIERS = "JACKPOT_TYPE_DOES_NOT_SUPPORT_TIERS",
|
|
57
|
+
RNG_SEED_NOT_FOUND = "RNG_SEED_NOT_FOUND",
|
|
58
|
+
RNG_SEED_MISMATCH = "RNG_SEED_MISMATCH",
|
|
59
|
+
MASTER_HASH_INVALID = "MASTER_HASH_INVALID",
|
|
60
|
+
REPLAY_OUTCOME_MISMATCH = "REPLAY_OUTCOME_MISMATCH",
|
|
61
|
+
CONCURRENT_MODIFICATION = "CONCURRENT_MODIFICATION",
|
|
62
|
+
ACCOUNT_LOCKED = "ACCOUNT_LOCKED",
|
|
63
|
+
DAILY_LIMIT_EXCEEDED = "DAILY_LIMIT_EXCEEDED",
|
|
64
|
+
INVALID_AMOUNT = "INVALID_AMOUNT",
|
|
65
|
+
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE"
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=internal-error-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-error-code.d.ts","sourceRoot":"","sources":["../../../src/common/error-handling/internal-error-code.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;IACvB,qBAAqB,0BAA0B;IAC/C,kBAAkB,uBAAuB;IACzC,qBAAqB,0BAA0B;IAE/C,cAAc,mBAAmB;IACjC,qBAAqB,0BAA0B;IAC/C,yDAAyD,8DAA8D;IACvH,uBAAuB,4BAA4B;IACnD,6BAA6B,kCAAkC;IAC/D,wBAAwB,6BAA6B;IACrD,wBAAwB,6BAA6B;IACrD,wBAAwB,6BAA6B;IACrD,iBAAiB,sBAAsB;IACvC,4BAA4B,iCAAiC;IAC7D,uBAAuB,4BAA4B;IAEnD,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;IACvC,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,wBAAwB,6BAA6B;IACrD,kBAAkB,uBAAuB;IACzC,yBAAyB,8BAA8B;IACvD,kBAAkB,uBAAuB;IACzC,4BAA4B,iCAAiC;IAC7D,2BAA2B,gCAAgC;IAC3D,sBAAsB,2BAA2B;IACjD,4BAA4B,iCAAiC;IAC7D,eAAe,oBAAoB;IAEnC,qBAAqB,0BAA0B;IAC/C,qBAAqB,0BAA0B;IAC/C,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,uBAAuB,4BAA4B;IACnD,YAAY,iBAAiB;IAC7B,sBAAsB,2BAA2B;IACjD,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,kCAAkC,uCAAuC;IACzE,6BAA6B,kCAAkC;IAC/D,sCAAsC,2CAA2C;IAGjF,wBAAwB,6BAA6B;IAErD,qBAAqB,0BAA0B;IAC/C,kCAAkC,uCAAuC;IACzE,kBAAkB,uBAAuB;IAGzC,+BAA+B,oCAAoC;IAGnE,mBAAmB,wBAAwB;IAG3C,sBAAsB,2BAA2B;IACjD,sBAAsB,2BAA2B;IACjD,+BAA+B,oCAAoC;IACnE,+BAA+B,oCAAoC;IACnE,2CAA2C,gDAAgD;IAC3F,mCAAmC,wCAAwC;IAG3E,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,mBAAmB,wBAAwB;IAC3C,uBAAuB,4BAA4B;IAEnD,uBAAuB,4BAA4B;IAEnD,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAC7C,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;CAC5C"}
|