@truelab/trueserver 0.0.4 → 0.1.0
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/CHANGELOG.md +67 -0
- package/MIGRATION.md +508 -0
- package/README.md +114 -94
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +9 -5
- package/dist/application.js.map +1 -1
- package/dist/examples.d.ts +1 -0
- package/dist/examples.d.ts.map +1 -1
- package/dist/examples.js +3 -1
- package/dist/examples.js.map +1 -1
- package/dist/helpers/config.helper.d.ts +9 -1
- package/dist/helpers/config.helper.d.ts.map +1 -1
- package/dist/helpers/config.helper.js +29 -0
- package/dist/helpers/config.helper.js.map +1 -1
- package/dist/helpers/errors.helper.d.ts +19 -0
- package/dist/helpers/errors.helper.d.ts.map +1 -0
- package/dist/helpers/errors.helper.js +21 -0
- package/dist/helpers/errors.helper.js.map +1 -0
- package/dist/helpers/fastify.helper.d.ts +5 -1
- package/dist/helpers/fastify.helper.d.ts.map +1 -1
- package/dist/helpers/fastify.helper.js +3 -1
- package/dist/helpers/fastify.helper.js.map +1 -1
- package/dist/helpers/handlers.helper.d.ts +10 -1
- package/dist/helpers/handlers.helper.d.ts.map +1 -1
- package/dist/helpers/handlers.helper.js +2 -1
- package/dist/helpers/handlers.helper.js.map +1 -1
- package/dist/helpers/money.helper.d.ts +13 -0
- package/dist/helpers/money.helper.d.ts.map +1 -0
- package/dist/helpers/money.helper.js +29 -0
- package/dist/helpers/money.helper.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/plugins/404.plugin.d.ts.map +1 -1
- package/dist/plugins/404.plugin.js +2 -1
- package/dist/plugins/404.plugin.js.map +1 -1
- package/dist/plugins/apikey.plugin.d.ts.map +1 -1
- package/dist/plugins/apikey.plugin.js +6 -7
- package/dist/plugins/apikey.plugin.js.map +1 -1
- package/dist/plugins/error.plugin.d.ts.map +1 -1
- package/dist/plugins/error.plugin.js +6 -2
- package/dist/plugins/error.plugin.js.map +1 -1
- package/dist/plugins/sentry.plugin.d.ts.map +1 -1
- package/dist/plugins/sentry.plugin.js +1 -2
- package/dist/plugins/sentry.plugin.js.map +1 -1
- package/dist/plugins/swagger.plugin.d.ts.map +1 -1
- package/dist/plugins/swagger.plugin.js +5 -1
- package/dist/plugins/swagger.plugin.js.map +1 -1
- package/dist/routes/checksum/checksum.route.d.ts +3 -0
- package/dist/routes/checksum/checksum.route.d.ts.map +1 -0
- package/dist/routes/checksum/checksum.route.js +21 -0
- package/dist/routes/checksum/checksum.route.js.map +1 -0
- package/dist/routes/checksum/index.d.ts +3 -0
- package/dist/routes/checksum/index.d.ts.map +1 -0
- package/dist/routes/checksum/index.js +12 -0
- package/dist/routes/checksum/index.js.map +1 -0
- package/dist/routes/client/client.route.d.ts +3 -0
- package/dist/routes/client/client.route.d.ts.map +1 -0
- package/dist/routes/{client.route.js → client/client.route.js} +5 -5
- package/dist/routes/client/client.route.js.map +1 -0
- package/dist/routes/client/index.d.ts +3 -0
- package/dist/routes/client/index.d.ts.map +1 -0
- package/dist/routes/client/index.js +12 -0
- package/dist/routes/client/index.js.map +1 -0
- package/dist/routes/config/config.route.js +1 -1
- package/dist/routes/config/config.route.js.map +1 -1
- package/dist/routes/config/config.route.validate.plugin.d.ts.map +1 -1
- package/dist/routes/config/config.route.validate.plugin.js +48 -17
- package/dist/routes/config/config.route.validate.plugin.js.map +1 -1
- package/dist/routes/play/play.route.validate.plugin.d.ts +10 -9
- package/dist/routes/play/play.route.validate.plugin.d.ts.map +1 -1
- package/dist/routes/play/play.route.validate.plugin.js +90 -39
- package/dist/routes/play/play.route.validate.plugin.js.map +1 -1
- package/dist/routes/validate/validate.route.validate.plugin.d.ts.map +1 -1
- package/dist/routes/validate/validate.route.validate.plugin.js +5 -4
- package/dist/routes/validate/validate.route.validate.plugin.js.map +1 -1
- package/dist/routes-public/healthcheck.route.d.ts.map +1 -0
- package/dist/{routes → routes-public}/healthcheck.route.js +4 -10
- package/dist/routes-public/healthcheck.route.js.map +1 -0
- package/dist/schemas/checksum.schema.d.ts +11 -0
- package/dist/schemas/checksum.schema.d.ts.map +1 -0
- package/dist/schemas/checksum.schema.js +26 -0
- package/dist/schemas/checksum.schema.js.map +1 -0
- package/dist/schemas/client.schema.d.ts +1 -1
- package/dist/schemas/client.schema.js +4 -4
- package/dist/schemas/client.schema.js.map +1 -1
- package/dist/schemas/config.schema.d.ts +17 -20
- package/dist/schemas/config.schema.d.ts.map +1 -1
- package/dist/schemas/config.schema.js +42 -43
- package/dist/schemas/config.schema.js.map +1 -1
- package/dist/schemas/examples/checksum.schema.examples.d.ts +3 -0
- package/dist/schemas/examples/checksum.schema.examples.d.ts.map +1 -0
- package/dist/schemas/examples/checksum.schema.examples.js +26 -0
- package/dist/schemas/examples/checksum.schema.examples.js.map +1 -0
- package/dist/schemas/examples/client.schema.examples.d.ts.map +1 -1
- package/dist/schemas/examples/client.schema.examples.js +15 -18
- package/dist/schemas/examples/client.schema.examples.js.map +1 -1
- package/dist/schemas/examples/config.schema.examples.d.ts.map +1 -1
- package/dist/schemas/examples/config.schema.examples.js +65 -33
- package/dist/schemas/examples/config.schema.examples.js.map +1 -1
- package/dist/schemas/examples/healthcheck.schema.examples.d.ts.map +1 -1
- package/dist/schemas/examples/healthcheck.schema.examples.js +3 -14
- package/dist/schemas/examples/healthcheck.schema.examples.js.map +1 -1
- package/dist/schemas/examples/play.schema.examples.d.ts.map +1 -1
- package/dist/schemas/examples/play.schema.examples.js +94 -130
- package/dist/schemas/examples/play.schema.examples.js.map +1 -1
- package/dist/schemas/examples/validate.schema.examples.d.ts.map +1 -1
- package/dist/schemas/examples/validate.schema.examples.js +51 -41
- package/dist/schemas/examples/validate.schema.examples.js.map +1 -1
- package/dist/schemas/healthcheck.schema.d.ts +2 -20
- package/dist/schemas/healthcheck.schema.d.ts.map +1 -1
- package/dist/schemas/healthcheck.schema.js +10 -41
- package/dist/schemas/healthcheck.schema.js.map +1 -1
- package/dist/schemas/play.schema.d.ts +22 -17
- package/dist/schemas/play.schema.d.ts.map +1 -1
- package/dist/schemas/play.schema.js +37 -45
- package/dist/schemas/play.schema.js.map +1 -1
- package/dist/schemas/shared.d.ts +13 -21
- package/dist/schemas/shared.d.ts.map +1 -1
- package/dist/schemas/shared.js +56 -72
- package/dist/schemas/shared.js.map +1 -1
- package/dist/schemas/validate.schema.d.ts +11 -7
- package/dist/schemas/validate.schema.d.ts.map +1 -1
- package/dist/schemas/validate.schema.js +14 -16
- package/dist/schemas/validate.schema.js.map +1 -1
- package/package.json +5 -2
- package/dist/plugins/metrics.plugin.d.ts +0 -9
- package/dist/plugins/metrics.plugin.d.ts.map +0 -1
- package/dist/plugins/metrics.plugin.js +0 -24
- package/dist/plugins/metrics.plugin.js.map +0 -1
- package/dist/routes/client.route.d.ts +0 -3
- package/dist/routes/client.route.d.ts.map +0 -1
- package/dist/routes/client.route.js.map +0 -1
- package/dist/routes/healthcheck.route.d.ts.map +0 -1
- package/dist/routes/healthcheck.route.js.map +0 -1
- /package/dist/{routes → routes-public}/healthcheck.route.d.ts +0 -0
package/dist/schemas/shared.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccessErrorSchema = exports.RequestErrorSchema = exports.InternalErrorSchema = exports.HeadersSchema = exports.
|
|
3
|
+
exports.AccessErrorSchema = exports.RequestErrorSchema = exports.InternalErrorSchema = exports.HeadersSchema = exports.MetaSchema = exports.StakeModeSchema = exports.StakeSchema = exports.EEnvironment = exports.EStakeType = void 0;
|
|
4
4
|
const typebox_1 = require("typebox");
|
|
5
5
|
const env_helper_1 = require("../helpers/env.helper");
|
|
6
|
-
var ECategory;
|
|
7
|
-
(function (ECategory) {
|
|
8
|
-
ECategory["slots"] = "slots";
|
|
9
|
-
ECategory["cluster"] = "cluster";
|
|
10
|
-
ECategory["table"] = "table";
|
|
11
|
-
})(ECategory || (exports.ECategory = ECategory = {}));
|
|
12
6
|
var EStakeType;
|
|
13
7
|
(function (EStakeType) {
|
|
14
8
|
EStakeType["default"] = "default";
|
|
15
9
|
EStakeType["buy"] = "buy";
|
|
16
10
|
EStakeType["bonusBet"] = "bonusBet";
|
|
17
11
|
})(EStakeType || (exports.EStakeType = EStakeType = {}));
|
|
18
|
-
var EVolatility;
|
|
19
|
-
(function (EVolatility) {
|
|
20
|
-
EVolatility["variable"] = "Variable";
|
|
21
|
-
EVolatility["low"] = "Low";
|
|
22
|
-
EVolatility["medLow"] = "Medium - Low";
|
|
23
|
-
EVolatility["med"] = "Medium";
|
|
24
|
-
EVolatility["medHigh"] = "Medium - High";
|
|
25
|
-
EVolatility["high"] = "High";
|
|
26
|
-
EVolatility["veryHigh"] = "Very High";
|
|
27
|
-
})(EVolatility || (exports.EVolatility = EVolatility = {}));
|
|
28
12
|
var EEnvironment;
|
|
29
13
|
(function (EEnvironment) {
|
|
30
14
|
EEnvironment["development"] = "development";
|
|
@@ -33,115 +17,115 @@ var EEnvironment;
|
|
|
33
17
|
})(EEnvironment || (exports.EEnvironment = EEnvironment = {}));
|
|
34
18
|
exports.StakeSchema = typebox_1.Type.Object({
|
|
35
19
|
name: typebox_1.Type.String({
|
|
36
|
-
description: 'Stake mode name
|
|
20
|
+
description: 'Stake mode name. Must match one of StakeMode.name from /config',
|
|
37
21
|
}),
|
|
38
22
|
amount: typebox_1.Type.Number({
|
|
39
|
-
description: '
|
|
23
|
+
description: 'Total stake amount in currency units, already multiplied by StakeMode.bets AND by qty (when set). Formula: amount = baseBetAmount × StakeMode.bets × (qty ?? 1). baseBetAmount is the in-currency value of one base bet on the chosen coin/line combination (e.g. coinValue × coinRatio for fixed-line; coinValue × level for variable-line)',
|
|
40
24
|
exclusiveMinimum: 0,
|
|
41
25
|
}),
|
|
26
|
+
coinValue: typebox_1.Type.Optional(typebox_1.Type.Number({
|
|
27
|
+
description: 'Price of one coin in currency units. Needed by the Game Server to compute cashWin from coin-denominated math. Present only for games with a coin mechanic; omitted entirely for games without one (e.g. roulettes)',
|
|
28
|
+
exclusiveMinimum: 0,
|
|
29
|
+
})),
|
|
42
30
|
level: typebox_1.Type.Optional(typebox_1.Type.Integer({
|
|
43
|
-
description: '
|
|
31
|
+
description: 'Chosen bet level. Required when hasVariableLevels=true; must be one of variableLevels',
|
|
44
32
|
minimum: 0,
|
|
45
33
|
})),
|
|
46
34
|
qty: typebox_1.Type.Optional(typebox_1.Type.Integer({
|
|
47
|
-
description: '
|
|
35
|
+
description: 'Number of stakes of this mode placed (only when StakeMode.multiple=true; up to maxQty). Already factored into amount — consumers must NOT multiply amount × qty again',
|
|
48
36
|
minimum: 1,
|
|
49
37
|
})),
|
|
50
38
|
params: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
51
|
-
description: 'Custom
|
|
39
|
+
description: 'Custom player input defining round parameters. Only for StakeMode.parametric=true; format is game-specific',
|
|
52
40
|
})),
|
|
53
41
|
}, {
|
|
54
42
|
$id: 'Stake',
|
|
55
|
-
description: '
|
|
43
|
+
description: 'A bet built from a StakeMode',
|
|
56
44
|
additionalProperties: false,
|
|
57
45
|
});
|
|
58
46
|
exports.StakeModeSchema = typebox_1.Type.Object({
|
|
59
47
|
name: typebox_1.Type.String({
|
|
60
|
-
description: 'Stake mode
|
|
48
|
+
description: 'Stake mode identifier (e.g. "default", "buyBonus", "doubleStreet")',
|
|
61
49
|
}),
|
|
62
50
|
type: typebox_1.Type.Enum(EStakeType, {
|
|
63
|
-
description: '
|
|
51
|
+
description: 'One of EStakeType: default, buy, bonusBet',
|
|
64
52
|
}),
|
|
65
53
|
bets: typebox_1.Type.Number({
|
|
66
|
-
description: '
|
|
54
|
+
description: 'How much the player pays for this mode, as a multiplier of the base stake size',
|
|
67
55
|
exclusiveMinimum: 0,
|
|
68
56
|
}),
|
|
69
57
|
multiple: typebox_1.Type.Optional(typebox_1.Type.Boolean({
|
|
70
|
-
description: '
|
|
58
|
+
description: 'true if more than one stake of this mode can be placed at once',
|
|
71
59
|
})),
|
|
72
|
-
parametric: typebox_1.Type.Boolean({
|
|
73
|
-
description: 'Shows that stake mode may have custom additional data (chip value, slider range, etc.)',
|
|
74
|
-
}),
|
|
75
60
|
maxQty: typebox_1.Type.Optional(typebox_1.Type.Integer({
|
|
76
|
-
description: '
|
|
61
|
+
description: 'Only when multiple=true: maximum allowed number of such stakes',
|
|
77
62
|
minimum: 1,
|
|
78
63
|
})),
|
|
64
|
+
parametric: typebox_1.Type.Optional(typebox_1.Type.Boolean({
|
|
65
|
+
description: 'true if a stake of this mode carries an extra params payload that can affect the round. Absence is equivalent to false',
|
|
66
|
+
})),
|
|
79
67
|
}, {
|
|
80
68
|
$id: 'StakeMode',
|
|
81
|
-
description: '
|
|
69
|
+
description: 'Bet template the game advertises in /config → stakeModes',
|
|
70
|
+
additionalProperties: false,
|
|
71
|
+
});
|
|
72
|
+
exports.MetaSchema = typebox_1.Type.Object({
|
|
73
|
+
public: typebox_1.Type.Any({
|
|
74
|
+
description: 'Public part of meta — RGS may forward it to the client',
|
|
75
|
+
}),
|
|
76
|
+
private: typebox_1.Type.Any({
|
|
77
|
+
description: 'Private part of meta — never forwarded to the client',
|
|
78
|
+
}),
|
|
79
|
+
}, {
|
|
80
|
+
$id: 'Meta',
|
|
81
|
+
description: 'Game-specific state carried across /play calls. Shape is opaque to RGS and to this package',
|
|
82
82
|
additionalProperties: false,
|
|
83
83
|
});
|
|
84
84
|
exports.HeadersSchema = typebox_1.Type.Object({
|
|
85
85
|
[(0, env_helper_1.getenv)('API_HEADER', 'x-api-key')]: typebox_1.Type.String({
|
|
86
|
-
description: '
|
|
86
|
+
description: 'Shared API key used to authenticate all RGS → Game Server calls',
|
|
87
87
|
examples: ['test'],
|
|
88
88
|
}),
|
|
89
89
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
description: 'Always false',
|
|
90
|
+
const errorEnvelopeProps = {
|
|
91
|
+
status: typebox_1.Type.Literal(false, {
|
|
92
|
+
description: 'Always false for error responses',
|
|
93
|
+
}),
|
|
94
|
+
code: typebox_1.Type.Integer({
|
|
95
|
+
description: 'Machine-readable error code (1xxx validation, 2xxx auth, 4xxx business, 9xxx internal)',
|
|
93
96
|
}),
|
|
94
97
|
message: typebox_1.Type.String({
|
|
95
|
-
description: '
|
|
98
|
+
description: 'Human-readable description of the failure',
|
|
96
99
|
}),
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})),
|
|
100
|
-
}, {
|
|
100
|
+
};
|
|
101
|
+
exports.InternalErrorSchema = typebox_1.Type.Object(errorEnvelopeProps, {
|
|
101
102
|
$id: 'InternalError',
|
|
102
|
-
description: '
|
|
103
|
+
description: 'Server-side failure',
|
|
103
104
|
additionalProperties: false,
|
|
104
105
|
examples: [{
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
status: false,
|
|
107
|
+
code: 9001,
|
|
108
|
+
message: 'Unhandled exception',
|
|
107
109
|
}],
|
|
108
110
|
});
|
|
109
|
-
exports.RequestErrorSchema = typebox_1.Type.Object({
|
|
110
|
-
ok: typebox_1.Type.Boolean({
|
|
111
|
-
description: 'Always false',
|
|
112
|
-
}),
|
|
113
|
-
message: typebox_1.Type.String({
|
|
114
|
-
description: 'Error message',
|
|
115
|
-
}),
|
|
116
|
-
custom: typebox_1.Type.Optional(typebox_1.Type.Any({
|
|
117
|
-
description: 'Any additional data about error',
|
|
118
|
-
})),
|
|
119
|
-
}, {
|
|
111
|
+
exports.RequestErrorSchema = typebox_1.Type.Object(errorEnvelopeProps, {
|
|
120
112
|
$id: 'RequestError',
|
|
121
|
-
description: '
|
|
113
|
+
description: 'Malformed body, invalid parameters or a domain-rule rejection',
|
|
122
114
|
additionalProperties: false,
|
|
123
115
|
examples: [{
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
status: false,
|
|
117
|
+
code: 1001,
|
|
118
|
+
message: "body must have required property 'isDemo'",
|
|
126
119
|
}],
|
|
127
120
|
});
|
|
128
|
-
exports.AccessErrorSchema = typebox_1.Type.Object({
|
|
129
|
-
ok: typebox_1.Type.Boolean({
|
|
130
|
-
description: 'Always false',
|
|
131
|
-
}),
|
|
132
|
-
message: typebox_1.Type.String({
|
|
133
|
-
description: 'Error message',
|
|
134
|
-
}),
|
|
135
|
-
custom: typebox_1.Type.Optional(typebox_1.Type.Any({
|
|
136
|
-
description: 'Any additional data about error',
|
|
137
|
-
})),
|
|
138
|
-
}, {
|
|
121
|
+
exports.AccessErrorSchema = typebox_1.Type.Object(errorEnvelopeProps, {
|
|
139
122
|
$id: 'AccessError',
|
|
140
|
-
description: '
|
|
123
|
+
description: 'Missing or invalid X-API-KEY',
|
|
141
124
|
additionalProperties: false,
|
|
142
125
|
examples: [{
|
|
143
|
-
|
|
144
|
-
|
|
126
|
+
status: false,
|
|
127
|
+
code: 2001,
|
|
128
|
+
message: 'Invalid X-API-KEY',
|
|
145
129
|
}],
|
|
146
130
|
});
|
|
147
131
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../schemas/shared.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAEtC,sDAA8C;AAE9C,IAAY,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../schemas/shared.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAEtC,sDAA8C;AAE9C,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,mCAAqB,CAAA;AACzB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED,IAAY,YAIX;AAJD,WAAY,YAAY;IACpB,2CAA2B,CAAA;IAC3B,mCAAmB,CAAA;IACnB,yCAAyB,CAAA;AAC7B,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAUY,QAAA,WAAW,GAAG,cAAI,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,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CAAC,kBAAkB,EAAE;IAC/D,GAAG,EAAE,eAAe;IACpB,WAAW,EAAE,qBAAqB;IAClC,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC;YACP,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,qBAAqB;SACjC,CAAC;CACL,CAAC,CAAA;AAEW,QAAA,kBAAkB,GAAG,cAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAC9D,GAAG,EAAE,cAAc;IACnB,WAAW,EAAE,+DAA+D;IAC5E,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC;YACP,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,2CAA2C;SACvD,CAAC;CACL,CAAC,CAAA;AAEW,QAAA,iBAAiB,GAAG,cAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAC7D,GAAG,EAAE,aAAa;IAClB,WAAW,EAAE,8BAA8B;IAC3C,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC;YACP,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,mBAAmB;SAC/B,CAAC;CACL,CAAC,CAAA"}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { Static, Type } from 'typebox';
|
|
2
2
|
export declare const ValidateRequestSchema: Type.TObject<{
|
|
3
|
-
|
|
4
|
-
currencyDecimals: Type.
|
|
5
|
-
stakes: Type.
|
|
3
|
+
isDemo: Type.TBoolean;
|
|
4
|
+
currencyDecimals: Type.TInteger;
|
|
5
|
+
stakes: Type.TArray<Type.TObject<{
|
|
6
6
|
name: Type.TString;
|
|
7
7
|
amount: Type.TNumber;
|
|
8
|
+
coinValue: Type.TOptional<Type.TNumber>;
|
|
8
9
|
level: Type.TOptional<Type.TInteger>;
|
|
9
10
|
qty: Type.TOptional<Type.TInteger>;
|
|
10
11
|
params: Type.TOptional<Type.TString>;
|
|
11
|
-
}
|
|
12
|
+
}>>;
|
|
12
13
|
maxExposure: Type.TNumber;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
meta: Type.TOptional<Type.TObject<{
|
|
15
|
+
public: Type.TAny;
|
|
16
|
+
private: Type.TAny;
|
|
17
|
+
}>>;
|
|
15
18
|
}>;
|
|
16
19
|
export declare const ValidateReplySchema: Type.TObject<{
|
|
17
|
-
|
|
20
|
+
valid: Type.TBoolean;
|
|
21
|
+
reason: Type.TOptional<Type.TString>;
|
|
18
22
|
}>;
|
|
19
23
|
export type TValidateRequest = Static<typeof ValidateRequestSchema>;
|
|
20
24
|
export type TValidateReply = Static<typeof ValidateReplySchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.schema.d.ts","sourceRoot":"","sources":["../../schemas/validate.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAKtC,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"validate.schema.d.ts","sourceRoot":"","sources":["../../schemas/validate.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAKtC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;EAqBhC,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;EAW9B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACnE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
@@ -5,36 +5,34 @@ const typebox_1 = require("typebox");
|
|
|
5
5
|
const validate_schema_examples_1 = require("./examples/validate.schema.examples");
|
|
6
6
|
const shared_1 = require("./shared");
|
|
7
7
|
exports.ValidateRequestSchema = typebox_1.Type.Object({
|
|
8
|
-
|
|
9
|
-
description: 'true
|
|
8
|
+
isDemo: typebox_1.Type.Boolean({
|
|
9
|
+
description: 'true for demo sessions',
|
|
10
10
|
}),
|
|
11
|
-
currencyDecimals: typebox_1.Type.
|
|
12
|
-
description: '
|
|
11
|
+
currencyDecimals: typebox_1.Type.Integer({
|
|
12
|
+
description: 'Decimal places of the currency',
|
|
13
13
|
minimum: 0,
|
|
14
|
-
})
|
|
15
|
-
stakes: typebox_1.Type.
|
|
16
|
-
description: '
|
|
14
|
+
}),
|
|
15
|
+
stakes: typebox_1.Type.Array(shared_1.StakeSchema, {
|
|
16
|
+
description: 'The stake set the round would open with — same shape as the opening /play stakes',
|
|
17
17
|
minItems: 1,
|
|
18
|
-
})
|
|
18
|
+
}),
|
|
19
19
|
maxExposure: typebox_1.Type.Number({
|
|
20
20
|
description: 'Maximum available winning amount in currency',
|
|
21
21
|
exclusiveMinimum: 0,
|
|
22
22
|
}),
|
|
23
|
-
|
|
24
|
-
description: 'Private part of meta data (json object transformed to string). Inner data for calculating average bet, double up payouts, etc.',
|
|
25
|
-
})),
|
|
26
|
-
metaPublic: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
27
|
-
description: 'Public part of meta data (json object transformed to string). Visual progress of cumulative features for client side or something like that',
|
|
28
|
-
})),
|
|
23
|
+
meta: typebox_1.Type.Optional(shared_1.MetaSchema),
|
|
29
24
|
}, {
|
|
30
25
|
$id: 'ValidateRequest',
|
|
31
26
|
additionalProperties: false,
|
|
32
27
|
'x-examples': validate_schema_examples_1.validateRequestExamples,
|
|
33
28
|
});
|
|
34
29
|
exports.ValidateReplySchema = typebox_1.Type.Object({
|
|
35
|
-
|
|
36
|
-
description: '
|
|
30
|
+
valid: typebox_1.Type.Boolean({
|
|
31
|
+
description: 'true if the stake set may open a round; false → RGS rejects it',
|
|
37
32
|
}),
|
|
33
|
+
reason: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
34
|
+
description: 'Human-readable rejection reason (for RGS logs; not shown to the player)',
|
|
35
|
+
})),
|
|
38
36
|
}, {
|
|
39
37
|
$id: 'ValidateReply',
|
|
40
38
|
additionalProperties: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.schema.js","sourceRoot":"","sources":["../../schemas/validate.schema.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAEtC,kFAAoG;AACpG,
|
|
1
|
+
{"version":3,"file":"validate.schema.js","sourceRoot":"","sources":["../../schemas/validate.schema.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAEtC,kFAAoG;AACpG,qCAAkD;AAErC,QAAA,qBAAqB,GAAG,cAAI,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,cAAI,CAAC,OAAO,CAAC;QACjB,WAAW,EAAE,wBAAwB;KACxC,CAAC;IACF,gBAAgB,EAAE,cAAI,CAAC,OAAO,CAAC;QAC3B,WAAW,EAAE,gCAAgC;QAC7C,OAAO,EAAE,CAAC;KACb,CAAC;IACF,MAAM,EAAE,cAAI,CAAC,KAAK,CAAC,oBAAW,EAAE;QAC5B,WAAW,EAAE,kFAAkF;QAC/F,QAAQ,EAAE,CAAC;KACd,CAAC;IACF,WAAW,EAAE,cAAI,CAAC,MAAM,CAAC;QACrB,WAAW,EAAE,8CAA8C;QAC3D,gBAAgB,EAAE,CAAC;KACtB,CAAC;IACF,IAAI,EAAE,cAAI,CAAC,QAAQ,CAAC,mBAAU,CAAC;CAClC,EAAE;IACC,GAAG,EAAE,iBAAiB;IACtB,oBAAoB,EAAE,KAAK;IAC3B,YAAY,EAAE,kDAAuB;CACxC,CAAC,CAAA;AAEW,QAAA,mBAAmB,GAAG,cAAI,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,cAAI,CAAC,OAAO,CAAC;QAChB,WAAW,EAAE,gEAAgE;KAChF,CAAC;IACF,MAAM,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,CAAC;QAC9B,WAAW,EAAE,yEAAyE;KACzF,CAAC,CAAC;CACN,EAAE;IACC,GAAG,EAAE,eAAe;IACpB,oBAAoB,EAAE,KAAK;IAC3B,YAAY,EAAE,gDAAqB;CACtC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truelab/trueserver",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "TrueLab Fastify server package: routes, schemas, and plugins for TrueLab game backends",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
33
|
"README.md",
|
|
34
|
-
"CHANGELOG.md"
|
|
34
|
+
"CHANGELOG.md",
|
|
35
|
+
"MIGRATION.md"
|
|
35
36
|
],
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=22.12"
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
"@fastify/type-provider-typebox": "^6.1.0",
|
|
69
70
|
"@immobiliarelabs/fastify-sentry": "^9.0.1",
|
|
70
71
|
"ajv": "^8.20.0",
|
|
72
|
+
"big.js": "^6.2.2",
|
|
71
73
|
"dotenv": "^17.4.2",
|
|
72
74
|
"fastify": "^5.8.5",
|
|
73
75
|
"fastify-plugin": "^5.1.0",
|
|
@@ -78,6 +80,7 @@
|
|
|
78
80
|
"devDependencies": {
|
|
79
81
|
"@babel/core": "^7.29.0",
|
|
80
82
|
"@babel/preset-env": "^7.29.5",
|
|
83
|
+
"@types/big.js": "^6.2.2",
|
|
81
84
|
"@types/jest": "^30.0.0",
|
|
82
85
|
"@types/node": "^25.8.0",
|
|
83
86
|
"jest": "^30.4.2",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TMetrics } from '../schemas/healthcheck.schema';
|
|
2
|
-
declare module 'fastify' {
|
|
3
|
-
interface FastifyInstance {
|
|
4
|
-
metrics: TMetrics;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
declare const metricsPlugin: (fastify: import("../helpers/fastify.helper").FastifyTypebox) => Promise<void>;
|
|
8
|
-
export default metricsPlugin;
|
|
9
|
-
//# sourceMappingURL=metrics.plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.plugin.d.ts","sourceRoot":"","sources":["../../plugins/metrics.plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD,OAAO,QAAQ,SAAS,CAAC;IACrB,UAAU,eAAe;QACrB,OAAO,EAAE,QAAQ,CAAA;KACpB;CACJ;AASD,QAAA,MAAM,aAAa,gFAYjB,CAAA;AAEF,eAAe,aAAa,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable no-param-reassign */
|
|
4
|
-
const fastify_helper_1 = require("../helpers/fastify.helper");
|
|
5
|
-
const metricsSingleton = {
|
|
6
|
-
requests: {
|
|
7
|
-
success: 0,
|
|
8
|
-
failed: 0,
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
const metricsPlugin = (0, fastify_helper_1.registerPlugin)(async (fastify) => {
|
|
12
|
-
fastify.decorate('metrics', metricsSingleton);
|
|
13
|
-
fastify.addHook('onResponse', (_request, reply, done) => {
|
|
14
|
-
if (reply.raw.statusCode < 400) {
|
|
15
|
-
fastify.metrics.requests.success += 1;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
fastify.metrics.requests.failed += 1;
|
|
19
|
-
}
|
|
20
|
-
done();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
exports.default = metricsPlugin;
|
|
24
|
-
//# sourceMappingURL=metrics.plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.plugin.js","sourceRoot":"","sources":["../../plugins/metrics.plugin.ts"],"names":[],"mappings":";;AAAA,sCAAsC;AACtC,8DAA0D;AAS1D,MAAM,gBAAgB,GAAa;IAC/B,QAAQ,EAAE;QACN,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,CAAC;KACZ;CACJ,CAAA;AAED,MAAM,aAAa,GAAG,IAAA,+BAAc,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAE7C,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACpD,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;YAC7B,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;QACzC,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAA;QACxC,CAAC;QAED,IAAI,EAAE,CAAA;IACV,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA;AAEF,kBAAe,aAAa,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.route.d.ts","sourceRoot":"","sources":["../../routes/client.route.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,WAAW,gFAYf,CAAA;AAEF,eAAe,WAAW,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.route.js","sourceRoot":"","sources":["../../routes/client.route.ts"],"names":[],"mappings":";;AAAA,8DAAyD;AACzD,gEAAqD;AACrD,4DAA4D;AAC5D,8CAE0B;AAE1B,MAAM,WAAW,GAAG,IAAA,8BAAa,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IAChD,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;QACpB,MAAM,EAAE;YACJ,QAAQ,EAAE;gBACN,GAAG,EAAE,iCAAiB;gBACtB,GAAG,EAAE,2BAAkB;gBACvB,GAAG,EAAE,0BAAiB;gBACtB,GAAG,EAAE,4BAAmB;aAC3B;YACD,OAAO,EAAE,sBAAa;SACzB;KACJ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,0BAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;AACtF,CAAC,CAAC,CAAA;AAEF,kBAAe,WAAW,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"healthcheck.route.d.ts","sourceRoot":"","sources":["../../routes/healthcheck.route.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,gBAAgB,gFA4BpB,CAAA;AAEF,eAAe,gBAAgB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"healthcheck.route.js","sourceRoot":"","sources":["../../routes/healthcheck.route.ts"],"names":[],"mappings":";;AAAA,4DAAwD;AACxD,sDAAiD;AACjD,8DAAyD;AACzD,sEAAsE;AACtE,8CAE0B;AAE1B,MAAM,gBAAgB,GAAG,IAAA,8BAAa,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACrD,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;QACzB,MAAM,EAAE;YACJ,QAAQ,EAAE;gBACN,GAAG,EAAE,2CAAsB;gBAC3B,GAAG,EAAE,2BAAkB;gBACvB,GAAG,EAAE,0BAAiB;gBACtB,GAAG,EAAE,4BAAmB;aAC3B;YACD,OAAO,EAAE,sBAAa;SACzB;KACJ,EAAE,GAAG,EAAE,CAAC,CAAC;QACN,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAA,6BAAa,GAAE,CAAC,IAAI;QAC7B,WAAW,EAAE,IAAA,sBAAS,EAClB,qBAAY,CAAC,WAAW,EACxB,qBAAY,CAAC,OAAO,EACpB,qBAAY,CAAC,UAAU,CAC1B;QACD,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;QAC/B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE;YACN,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM;SAC3B;KACJ,CAAC,CAAC,CAAA;AACP,CAAC,CAAC,CAAA;AAEF,kBAAe,gBAAgB,CAAA"}
|
|
File without changes
|