@truelab/trueserver 0.0.3
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 +36 -0
- package/README.md +220 -0
- package/dist/application.d.ts +7 -0
- package/dist/application.d.ts.map +1 -0
- package/dist/application.js +41 -0
- package/dist/application.js.map +1 -0
- package/dist/helpers/config.helper.d.ts +5 -0
- package/dist/helpers/config.helper.d.ts.map +1 -0
- package/dist/helpers/config.helper.js +12 -0
- package/dist/helpers/config.helper.js.map +1 -0
- package/dist/helpers/env.helper.d.ts +5 -0
- package/dist/helpers/env.helper.d.ts.map +1 -0
- package/dist/helpers/env.helper.js +29 -0
- package/dist/helpers/env.helper.js.map +1 -0
- package/dist/helpers/fastify.helper.d.ts +9 -0
- package/dist/helpers/fastify.helper.d.ts.map +1 -0
- package/dist/helpers/fastify.helper.js +27 -0
- package/dist/helpers/fastify.helper.js.map +1 -0
- package/dist/helpers/handlers.helper.d.ts +39 -0
- package/dist/helpers/handlers.helper.d.ts.map +1 -0
- package/dist/helpers/handlers.helper.js +25 -0
- package/dist/helpers/handlers.helper.js.map +1 -0
- package/dist/helpers/logger.helper.d.ts +6 -0
- package/dist/helpers/logger.helper.d.ts.map +1 -0
- package/dist/helpers/logger.helper.js +21 -0
- package/dist/helpers/logger.helper.js.map +1 -0
- package/dist/helpers/pkg-version.helper.d.ts +5 -0
- package/dist/helpers/pkg-version.helper.d.ts.map +1 -0
- package/dist/helpers/pkg-version.helper.js +22 -0
- package/dist/helpers/pkg-version.helper.js.map +1 -0
- package/dist/helpers/random.helper.d.ts +7 -0
- package/dist/helpers/random.helper.d.ts.map +1 -0
- package/dist/helpers/random.helper.js +18 -0
- package/dist/helpers/random.helper.js.map +1 -0
- package/dist/helpers/tests.helper.d.ts +9 -0
- package/dist/helpers/tests.helper.d.ts.map +1 -0
- package/dist/helpers/tests.helper.js +45 -0
- package/dist/helpers/tests.helper.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/404.plugin.d.ts +3 -0
- package/dist/plugins/404.plugin.d.ts.map +1 -0
- package/dist/plugins/404.plugin.js +10 -0
- package/dist/plugins/404.plugin.js.map +1 -0
- package/dist/plugins/apikey.plugin.d.ts +3 -0
- package/dist/plugins/apikey.plugin.d.ts.map +1 -0
- package/dist/plugins/apikey.plugin.js +18 -0
- package/dist/plugins/apikey.plugin.js.map +1 -0
- package/dist/plugins/cors.plugin.d.ts +3 -0
- package/dist/plugins/cors.plugin.d.ts.map +1 -0
- package/dist/plugins/cors.plugin.js +15 -0
- package/dist/plugins/cors.plugin.js.map +1 -0
- package/dist/plugins/error.plugin.d.ts +3 -0
- package/dist/plugins/error.plugin.d.ts.map +1 -0
- package/dist/plugins/error.plugin.js +18 -0
- package/dist/plugins/error.plugin.js.map +1 -0
- package/dist/plugins/logger.plugin.d.ts +3 -0
- package/dist/plugins/logger.plugin.d.ts.map +1 -0
- package/dist/plugins/logger.plugin.js +51 -0
- package/dist/plugins/logger.plugin.js.map +1 -0
- package/dist/plugins/metrics.plugin.d.ts +9 -0
- package/dist/plugins/metrics.plugin.d.ts.map +1 -0
- package/dist/plugins/metrics.plugin.js +24 -0
- package/dist/plugins/metrics.plugin.js.map +1 -0
- package/dist/plugins/sentry.plugin.d.ts +3 -0
- package/dist/plugins/sentry.plugin.d.ts.map +1 -0
- package/dist/plugins/sentry.plugin.js +24 -0
- package/dist/plugins/sentry.plugin.js.map +1 -0
- package/dist/plugins/swagger.plugin.d.ts +3 -0
- package/dist/plugins/swagger.plugin.d.ts.map +1 -0
- package/dist/plugins/swagger.plugin.js +58 -0
- package/dist/plugins/swagger.plugin.js.map +1 -0
- package/dist/routes/client.route.d.ts +3 -0
- package/dist/routes/client.route.d.ts.map +1 -0
- package/dist/routes/client.route.js +21 -0
- package/dist/routes/client.route.js.map +1 -0
- package/dist/routes/config/config.route.d.ts +3 -0
- package/dist/routes/config/config.route.d.ts.map +1 -0
- package/dist/routes/config/config.route.js +21 -0
- package/dist/routes/config/config.route.js.map +1 -0
- package/dist/routes/config/config.route.validate.plugin.d.ts +3 -0
- package/dist/routes/config/config.route.validate.plugin.d.ts.map +1 -0
- package/dist/routes/config/config.route.validate.plugin.js +42 -0
- package/dist/routes/config/config.route.validate.plugin.js.map +1 -0
- package/dist/routes/config/index.d.ts +3 -0
- package/dist/routes/config/index.d.ts.map +1 -0
- package/dist/routes/config/index.js +14 -0
- package/dist/routes/config/index.js.map +1 -0
- package/dist/routes/healthcheck.route.d.ts +3 -0
- package/dist/routes/healthcheck.route.d.ts.map +1 -0
- package/dist/routes/healthcheck.route.js +34 -0
- package/dist/routes/healthcheck.route.js.map +1 -0
- package/dist/routes/play/index.d.ts +3 -0
- package/dist/routes/play/index.d.ts.map +1 -0
- package/dist/routes/play/index.js +14 -0
- package/dist/routes/play/index.js.map +1 -0
- package/dist/routes/play/play.route.d.ts +3 -0
- package/dist/routes/play/play.route.d.ts.map +1 -0
- package/dist/routes/play/play.route.js +22 -0
- package/dist/routes/play/play.route.js.map +1 -0
- package/dist/routes/play/play.route.validate.plugin.d.ts +13 -0
- package/dist/routes/play/play.route.validate.plugin.d.ts.map +1 -0
- package/dist/routes/play/play.route.validate.plugin.js +108 -0
- package/dist/routes/play/play.route.validate.plugin.js.map +1 -0
- package/dist/routes/validate/index.d.ts +3 -0
- package/dist/routes/validate/index.d.ts.map +1 -0
- package/dist/routes/validate/index.js +14 -0
- package/dist/routes/validate/index.js.map +1 -0
- package/dist/routes/validate/validate.route.d.ts +3 -0
- package/dist/routes/validate/validate.route.d.ts.map +1 -0
- package/dist/routes/validate/validate.route.js +22 -0
- package/dist/routes/validate/validate.route.js.map +1 -0
- package/dist/routes/validate/validate.route.validate.plugin.d.ts +3 -0
- package/dist/routes/validate/validate.route.validate.plugin.d.ts.map +1 -0
- package/dist/routes/validate/validate.route.validate.plugin.js +28 -0
- package/dist/routes/validate/validate.route.validate.plugin.js.map +1 -0
- package/dist/schemas/client.schema.d.ts +9 -0
- package/dist/schemas/client.schema.d.ts.map +1 -0
- package/dist/schemas/client.schema.js +22 -0
- package/dist/schemas/client.schema.js.map +1 -0
- package/dist/schemas/config.schema.d.ts +34 -0
- package/dist/schemas/config.schema.d.ts.map +1 -0
- package/dist/schemas/config.schema.js +78 -0
- package/dist/schemas/config.schema.js.map +1 -0
- package/dist/schemas/examples/client.schema.examples.d.ts +3 -0
- package/dist/schemas/examples/client.schema.examples.d.ts.map +1 -0
- package/dist/schemas/examples/client.schema.examples.js +32 -0
- package/dist/schemas/examples/client.schema.examples.js.map +1 -0
- package/dist/schemas/examples/config.schema.examples.d.ts +3 -0
- package/dist/schemas/examples/config.schema.examples.d.ts.map +1 -0
- package/dist/schemas/examples/config.schema.examples.js +56 -0
- package/dist/schemas/examples/config.schema.examples.js.map +1 -0
- package/dist/schemas/examples/healthcheck.schema.examples.d.ts +3 -0
- package/dist/schemas/examples/healthcheck.schema.examples.d.ts.map +1 -0
- package/dist/schemas/examples/healthcheck.schema.examples.js +28 -0
- package/dist/schemas/examples/healthcheck.schema.examples.js.map +1 -0
- package/dist/schemas/examples/play.schema.examples.d.ts +4 -0
- package/dist/schemas/examples/play.schema.examples.d.ts.map +1 -0
- package/dist/schemas/examples/play.schema.examples.js +165 -0
- package/dist/schemas/examples/play.schema.examples.js.map +1 -0
- package/dist/schemas/examples/validate.schema.examples.d.ts +4 -0
- package/dist/schemas/examples/validate.schema.examples.d.ts.map +1 -0
- package/dist/schemas/examples/validate.schema.examples.js +100 -0
- package/dist/schemas/examples/validate.schema.examples.js.map +1 -0
- package/dist/schemas/healthcheck.schema.d.ts +31 -0
- package/dist/schemas/healthcheck.schema.d.ts.map +1 -0
- package/dist/schemas/healthcheck.schema.js +63 -0
- package/dist/schemas/healthcheck.schema.js.map +1 -0
- package/dist/schemas/play.schema.d.ts +34 -0
- package/dist/schemas/play.schema.d.ts.map +1 -0
- package/dist/schemas/play.schema.js +80 -0
- package/dist/schemas/play.schema.js.map +1 -0
- package/dist/schemas/shared.d.ts +71 -0
- package/dist/schemas/shared.d.ts.map +1 -0
- package/dist/schemas/shared.js +147 -0
- package/dist/schemas/shared.js.map +1 -0
- package/dist/schemas/validate.schema.d.ts +21 -0
- package/dist/schemas/validate.schema.d.ts.map +1 -0
- package/dist/schemas/validate.schema.js +43 -0
- package/dist/schemas/validate.schema.js.map +1 -0
- package/dist/test-utils.d.ts +6 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +13 -0
- package/dist/test-utils.js.map +1 -0
- package/package.json +80 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- NPM-пакет `@truelab/trueserver` (exports, dist, prepack, publishConfig)
|
|
11
|
+
- Bitbucket Pipelines: test / build / publish
|
|
12
|
+
|
|
13
|
+
## [0.0.2] - 2024-02-29
|
|
14
|
+
|
|
15
|
+
### Remove
|
|
16
|
+
- Play helper
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- Default swagger redirect (for dev)
|
|
20
|
+
- New stake level validation
|
|
21
|
+
- coinRatio/levels valiadtion
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Volatility, Hitrate, Min win are optional now (can be variable for some games)
|
|
25
|
+
- Currency decimals is optional for play/validate
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- Winning calculation
|
|
29
|
+
- Schema types (literals broke types)
|
|
30
|
+
- Orginized imports
|
|
31
|
+
- Game types enum ('casual' => 'table')
|
|
32
|
+
|
|
33
|
+
## [0.0.1] - 2024-02-18
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- Initial version
|
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# @truelab/trueserver
|
|
2
|
+
|
|
3
|
+
Fastify-based server package for TrueLab games.
|
|
4
|
+
|
|
5
|
+
The package provides ready-to-use HTTP routes, request/response validation, shared TypeBox schemas, API key checks, Sentry integration, and Swagger UI for local development. A game server only needs to register game metadata and route handlers.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Node.js 22.12+ (uses `require()` of an ESM-only `typebox` dependency)
|
|
10
|
+
- npm package access for `@truelab/trueserver`
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @truelab/trueserver
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
Register game config and handlers before building the Fastify app:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import {
|
|
24
|
+
Application,
|
|
25
|
+
ECategory,
|
|
26
|
+
EStakeType,
|
|
27
|
+
EVolatility,
|
|
28
|
+
handlers,
|
|
29
|
+
getenv,
|
|
30
|
+
logger,
|
|
31
|
+
registerGameConfig,
|
|
32
|
+
type TClientReply,
|
|
33
|
+
type TConfigReply,
|
|
34
|
+
type TPlayReply,
|
|
35
|
+
type TValidateReply,
|
|
36
|
+
} from '@truelab/trueserver'
|
|
37
|
+
|
|
38
|
+
const stakeModes = [{
|
|
39
|
+
name: 'default',
|
|
40
|
+
type: EStakeType.default,
|
|
41
|
+
bets: 1,
|
|
42
|
+
parametric: false,
|
|
43
|
+
multiple: false,
|
|
44
|
+
}]
|
|
45
|
+
|
|
46
|
+
registerGameConfig({
|
|
47
|
+
name: 'My Game',
|
|
48
|
+
stakeModes,
|
|
49
|
+
hasBuy: false,
|
|
50
|
+
hasChoice: false,
|
|
51
|
+
hasGamble: false,
|
|
52
|
+
hasMeta: false,
|
|
53
|
+
hasMultiStake: false,
|
|
54
|
+
hasValidation: false,
|
|
55
|
+
coinRatio: 10,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
handlers.register('client', async (): Promise<TClientReply> => ({
|
|
59
|
+
ok: true,
|
|
60
|
+
data: {},
|
|
61
|
+
}))
|
|
62
|
+
|
|
63
|
+
handlers.register('config', async (): Promise<TConfigReply> => ({
|
|
64
|
+
ok: true,
|
|
65
|
+
name: 'My Game',
|
|
66
|
+
category: ECategory.slots,
|
|
67
|
+
stakeModes,
|
|
68
|
+
rtp: 96,
|
|
69
|
+
hitrate: 25,
|
|
70
|
+
volatility: EVolatility.med,
|
|
71
|
+
hasMeta: false,
|
|
72
|
+
hasChoice: false,
|
|
73
|
+
hasBuy: false,
|
|
74
|
+
hasMultiStake: false,
|
|
75
|
+
hasValidation: false,
|
|
76
|
+
hasGamble: false,
|
|
77
|
+
freeroundsAllowed: false,
|
|
78
|
+
minWin: 0.1,
|
|
79
|
+
maxWin: 5000,
|
|
80
|
+
apiVersion: 0,
|
|
81
|
+
coinRatio: 10,
|
|
82
|
+
}))
|
|
83
|
+
|
|
84
|
+
handlers.register('play', async (): Promise<TPlayReply> => ({
|
|
85
|
+
ok: true,
|
|
86
|
+
rng: '[]',
|
|
87
|
+
finished: true,
|
|
88
|
+
results: {
|
|
89
|
+
response: '{}',
|
|
90
|
+
winCash: 0,
|
|
91
|
+
},
|
|
92
|
+
}))
|
|
93
|
+
|
|
94
|
+
handlers.register('validate', async (): Promise<TValidateReply> => ({
|
|
95
|
+
ok: true,
|
|
96
|
+
}))
|
|
97
|
+
|
|
98
|
+
async function main() {
|
|
99
|
+
const app = new Application()
|
|
100
|
+
const server = await app.build()
|
|
101
|
+
|
|
102
|
+
await server.listen({
|
|
103
|
+
host: getenv('HOST', 'localhost'),
|
|
104
|
+
port: Number.parseInt(getenv('PORT', '2980'), 10),
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
main().catch((error) => {
|
|
109
|
+
logger.error(error)
|
|
110
|
+
process.exit(1)
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`registerGameConfig` must be called before `app.build()`: validation plugins read this config while the server is being built.
|
|
115
|
+
|
|
116
|
+
## Runtime API
|
|
117
|
+
|
|
118
|
+
The server registers these routes:
|
|
119
|
+
|
|
120
|
+
| Method | Path | Handler | Description |
|
|
121
|
+
| ------ | ---- | ------- | ----------- |
|
|
122
|
+
| `POST` | `/client` | `handlers.register('client', ...)` | Client settings payload |
|
|
123
|
+
| `POST` | `/config` | `handlers.register('config', ...)` | Public game config |
|
|
124
|
+
| `POST` | `/play` | `handlers.register('play', ...)` | Game round calculation |
|
|
125
|
+
| `POST` | `/validate` | `handlers.register('validate', ...)` | Optional stake/meta validation |
|
|
126
|
+
| `POST` | `/healthcheck` | built in | Service status and metrics |
|
|
127
|
+
|
|
128
|
+
All `POST` routes require an API key header. By default the server expects `x-api-key: test`; configure it with `API_HEADER` and `API_KEY`.
|
|
129
|
+
|
|
130
|
+
`ROUTE_PREFIX` is applied to all routes. For example, `ROUTE_PREFIX=/api/game` turns `/play` into `/api/game/play`.
|
|
131
|
+
|
|
132
|
+
## Imports
|
|
133
|
+
|
|
134
|
+
Use the root entry for runtime code, schemas, enums, helpers, and public types:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import {
|
|
138
|
+
Application,
|
|
139
|
+
EStakeType,
|
|
140
|
+
PlayRequestSchema,
|
|
141
|
+
handlers,
|
|
142
|
+
registerGameConfig,
|
|
143
|
+
type TPlayReply,
|
|
144
|
+
} from '@truelab/trueserver'
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Test helpers are intentionally published through a separate entry:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { testBuild } from '@truelab/trueserver/test-utils'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Published code is compiled into `dist/`; package `exports` exposes only the public root entry and test utilities.
|
|
154
|
+
|
|
155
|
+
## Environment Variables
|
|
156
|
+
|
|
157
|
+
| Variable | Default | Description |
|
|
158
|
+
| -------- | ------- | ----------- |
|
|
159
|
+
| `HOST` | `localhost` | Listen host used by the consuming game server |
|
|
160
|
+
| `PORT` | `2980` | Listen port used by the consuming game server |
|
|
161
|
+
| `ROUTE_PREFIX` | empty | Prefix for all autoloaded routes |
|
|
162
|
+
| `API_HEADER` | `x-api-key` | Header name used by the API key plugin |
|
|
163
|
+
| `API_KEY` | `test` | Expected API key for `POST` requests |
|
|
164
|
+
| `LOG_LEVEL` | `error` | Pino log level |
|
|
165
|
+
| `APP_ENV` | unset | `dev`, `release`, or `master`; controls Swagger and environment mapping |
|
|
166
|
+
| `SENTRY_DSN` | unset | Sentry DSN |
|
|
167
|
+
| `SENTRY_RATE` | `0.01` | Sentry traces sample rate |
|
|
168
|
+
| `GAME_ID` | `0001` | Sentry `game.id` tag |
|
|
169
|
+
|
|
170
|
+
The environment helper imports `dotenv/config`, so `.env` is loaded when `@truelab/trueserver` is imported.
|
|
171
|
+
|
|
172
|
+
## Swagger
|
|
173
|
+
|
|
174
|
+
Swagger UI is enabled only for `APP_ENV=dev`.
|
|
175
|
+
|
|
176
|
+
- `GET /` redirects to `/docs`
|
|
177
|
+
- `GET /docs` serves Swagger UI
|
|
178
|
+
- `release` and `master` disable Swagger UI
|
|
179
|
+
|
|
180
|
+
When `ROUTE_PREFIX` is set, it affects game routes, not the Swagger UI route.
|
|
181
|
+
|
|
182
|
+
## Advanced Validation
|
|
183
|
+
|
|
184
|
+
The package validates both requests and successful replies with TypeBox schemas. It also performs game-specific checks based on `registerGameConfig`.
|
|
185
|
+
|
|
186
|
+
- `/config` checks stake modes and requires exactly one of `coinRatio` or `variableLevels`.
|
|
187
|
+
- `/play` checks stakes, choices, meta data, gamble flag, and reply consistency.
|
|
188
|
+
- `/validate` is available only when `hasValidation` is `true`.
|
|
189
|
+
- `test` data is rejected in production mapping (`APP_ENV=master` or unset).
|
|
190
|
+
|
|
191
|
+
For stepped games, set `hasChoice: true`; for games with meta state, set `hasMeta: true`; for line/table variants, use `variableLevels` instead of `coinRatio`.
|
|
192
|
+
|
|
193
|
+
## Test Utilities
|
|
194
|
+
|
|
195
|
+
Integration tests in consuming game servers can import Jest helpers from:
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import {
|
|
199
|
+
checkSchemaPropertyDescriptions,
|
|
200
|
+
testBuild,
|
|
201
|
+
testHeaders,
|
|
202
|
+
validator,
|
|
203
|
+
} from '@truelab/trueserver/test-utils'
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`test-utils` uses Jest globals (`expect`), so the consuming project should keep `jest` and usually `@types/jest` in `devDependencies`.
|
|
207
|
+
|
|
208
|
+
## Package Development
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npm test # run Jest tests
|
|
212
|
+
npm run build # compile TypeScript to dist/
|
|
213
|
+
npm pack # build and inspect the npm tarball
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`bitbucket-pipelines.yml` runs tests and build on the default branch. The custom `publish` pipeline publishes to npm with `NPM_PUBLISH_TOKEN`.
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
ISC
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../application.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAkB,MAAM,0BAA0B,CAAA;AAGzE,MAAM,CAAC,OAAO,OAAO,WAAW;IAC5B,MAAM,EAAE,cAAc,CAAA;;IAchB,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC;CAiBzC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const autoload_1 = __importDefault(require("@fastify/autoload"));
|
|
7
|
+
const fastify_1 = __importDefault(require("fastify"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fastify_helper_1 = require("./helpers/fastify.helper");
|
|
10
|
+
const logger_helper_1 = require("./helpers/logger.helper");
|
|
11
|
+
class Application {
|
|
12
|
+
server;
|
|
13
|
+
constructor() {
|
|
14
|
+
this.server = (0, fastify_1.default)({
|
|
15
|
+
ajv: {
|
|
16
|
+
customOptions: {
|
|
17
|
+
keywords: ['x-examples'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
logger: logger_helper_1.loggerOptions,
|
|
21
|
+
disableRequestLogging: true,
|
|
22
|
+
}).withTypeProvider();
|
|
23
|
+
}
|
|
24
|
+
async build() {
|
|
25
|
+
// Load plugins
|
|
26
|
+
await this.server.register(autoload_1.default, {
|
|
27
|
+
dir: path_1.default.join(__dirname, 'plugins'),
|
|
28
|
+
});
|
|
29
|
+
// Load routes
|
|
30
|
+
await this.server.register(autoload_1.default, {
|
|
31
|
+
dir: path_1.default.join(__dirname, 'routes'),
|
|
32
|
+
options: {
|
|
33
|
+
prefix: (0, fastify_helper_1.getRoutePrefix)(),
|
|
34
|
+
},
|
|
35
|
+
dirNameRoutePrefix: false,
|
|
36
|
+
});
|
|
37
|
+
return this.server;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = Application;
|
|
41
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../application.ts"],"names":[],"mappings":";;;;;AAAA,iEAA+C;AAE/C,sDAA6B;AAC7B,gDAAuB;AAEvB,6DAAyE;AACzE,2DAAuD;AAEvD,MAAqB,WAAW;IAC5B,MAAM,CAAgB;IAEtB;QACI,IAAI,CAAC,MAAM,GAAG,IAAA,iBAAO,EAAC;YAClB,GAAG,EAAE;gBACD,aAAa,EAAE;oBACX,QAAQ,EAAE,CAAC,YAAY,CAAC;iBAC3B;aACJ;YACD,MAAM,EAAE,6BAAa;YACrB,qBAAqB,EAAE,IAAI;SAC9B,CAAC,CAAC,gBAAgB,EAAuB,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,KAAK;QACX,eAAe;QACX,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAe,EAAE;YACxC,GAAG,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC;SACvC,CAAC,CAAA;QAEF,cAAc;QACd,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAe,EAAE;YACxC,GAAG,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;YACnC,OAAO,EAAE;gBACL,MAAM,EAAE,IAAA,+BAAc,GAAE;aAC3B;YACD,kBAAkB,EAAE,KAAK;SAC5B,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;CACJ;AAhCD,8BAgCC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TConfigReply } from '../schemas/config.schema';
|
|
2
|
+
export type TGameConfig = Pick<TConfigReply, 'name' | 'stakeModes' | 'hasBuy' | 'hasChoice' | 'hasGamble' | 'hasMeta' | 'hasMultiStake' | 'hasValidation' | 'variableLevels' | 'coinRatio'>;
|
|
3
|
+
export declare function registerGameConfig(config: TGameConfig): void;
|
|
4
|
+
export declare function getGameConfig(): TGameConfig;
|
|
5
|
+
//# sourceMappingURL=config.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.helper.d.ts","sourceRoot":"","sources":["../../helpers/config.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAC3C,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,WAAW,GACX,SAAS,GACT,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,WAAW,CACV,CAAA;AAID,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,QAErD;AAED,wBAAgB,aAAa,IAAI,WAAW,CAE3C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGameConfig = registerGameConfig;
|
|
4
|
+
exports.getGameConfig = getGameConfig;
|
|
5
|
+
let gameConfig;
|
|
6
|
+
function registerGameConfig(config) {
|
|
7
|
+
gameConfig = config;
|
|
8
|
+
}
|
|
9
|
+
function getGameConfig() {
|
|
10
|
+
return gameConfig;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=config.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.helper.js","sourceRoot":"","sources":["../../helpers/config.helper.ts"],"names":[],"mappings":";;AAiBA,gDAEC;AAED,sCAEC;AARD,IAAI,UAAuB,CAAA;AAE3B,SAAgB,kBAAkB,CAAC,MAAmB;IAClD,UAAU,GAAG,MAAM,CAAA;AACvB,CAAC;AAED,SAAgB,aAAa;IACzB,OAAO,UAAU,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
export declare function getenv<T = string>(name: string, def: T): T;
|
|
3
|
+
/** Вариации значений в зависимости от окружения */
|
|
4
|
+
export declare function variation<T>(devBranch: T, releaseBranch: T, masterBranch: T): T;
|
|
5
|
+
//# sourceMappingURL=env.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.helper.d.ts","sourceRoot":"","sources":["../../helpers/env.helper.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,wBAAgB,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAY1D;AAED,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAY/E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getenv = getenv;
|
|
4
|
+
exports.variation = variation;
|
|
5
|
+
require("dotenv/config");
|
|
6
|
+
function getenv(name, def) {
|
|
7
|
+
if (name in process.env) {
|
|
8
|
+
const value = process.env[name];
|
|
9
|
+
switch (value) {
|
|
10
|
+
case 'true': return true;
|
|
11
|
+
case 'false': return false;
|
|
12
|
+
default: return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return def;
|
|
16
|
+
}
|
|
17
|
+
/** Вариации значений в зависимости от окружения */
|
|
18
|
+
function variation(devBranch, releaseBranch, masterBranch) {
|
|
19
|
+
const variations = {
|
|
20
|
+
dev: devBranch,
|
|
21
|
+
release: releaseBranch,
|
|
22
|
+
master: masterBranch,
|
|
23
|
+
};
|
|
24
|
+
if (process.env.APP_ENV && process.env.APP_ENV in variations) {
|
|
25
|
+
return variations[process.env.APP_ENV];
|
|
26
|
+
}
|
|
27
|
+
return masterBranch;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=env.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.helper.js","sourceRoot":"","sources":["../../helpers/env.helper.ts"],"names":[],"mappings":";;AAEA,wBAYC;AAGD,8BAYC;AA7BD,yBAAsB;AAEtB,SAAgB,MAAM,CAAa,IAAY,EAAE,GAAM;IACnD,IAAI,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACtB,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAExC,QAAQ,KAAK,EAAE,CAAC;YACZ,KAAK,MAAM,CAAC,CAAC,OAAO,IAAoB,CAAA;YACxC,KAAK,OAAO,CAAC,CAAC,OAAO,KAAqB,CAAA;YAC1C,OAAO,CAAC,CAAC,OAAO,KAAU,CAAA;QAC9B,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAA;AACd,CAAC;AAED,mDAAmD;AACnD,SAAgB,SAAS,CAAI,SAAY,EAAE,aAAgB,EAAE,YAAe;IACxE,MAAM,UAAU,GAAyB;QACrC,GAAG,EAAE,SAAS;QACd,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,YAAY;KACvB,CAAA;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,UAAU,EAAE,CAAC;QAC3D,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC1C,CAAC;IAED,OAAO,YAAY,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox';
|
|
2
|
+
import { FastifyBaseLogger, FastifyError, FastifyInstance, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerDefault } from 'fastify';
|
|
3
|
+
export type FastifyTypebox = FastifyInstance<RawServerDefault, RawRequestDefaultExpression<RawServerDefault>, RawReplyDefaultExpression<RawServerDefault>, FastifyBaseLogger, TypeBoxTypeProvider>;
|
|
4
|
+
export declare function registerRoute(callback: (fastify: FastifyTypebox) => Promise<void>): (fastify: FastifyTypebox) => Promise<void>;
|
|
5
|
+
export declare function registerPlugin(callback: (fastify: FastifyTypebox) => Promise<void>): (fastify: FastifyTypebox) => Promise<void>;
|
|
6
|
+
export declare function getRoutePrefix(): string;
|
|
7
|
+
/** This is handled in error.plugin.ts */
|
|
8
|
+
export declare function httpError(message: string, statusCode?: number): FastifyError;
|
|
9
|
+
//# sourceMappingURL=fastify.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastify.helper.d.ts","sourceRoot":"","sources":["../../helpers/fastify.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EACH,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAChD,yBAAyB,EAAE,2BAA2B,EAAE,gBAAgB,EAC3E,MAAM,SAAS,CAAA;AAKhB,MAAM,MAAM,cAAc,GAAG,eAAe,CAC5C,gBAAgB,EAChB,2BAA2B,CAAC,gBAAgB,CAAC,EAC7C,yBAAyB,CAAC,gBAAgB,CAAC,EAC3C,iBAAiB,EACjB,mBAAmB,CAClB,CAAA;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAE,IAAI,CAAC,aAAjC,cAAc,KAAK,OAAO,CAAE,IAAI,CAAC,CAElF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAE,IAAI,CAAC,aAAjC,cAAc,KAAK,OAAO,CAAE,IAAI,CAAC,CAEnF;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,GAAE,MAAY,GAAG,YAAY,CAKjF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerRoute = registerRoute;
|
|
7
|
+
exports.registerPlugin = registerPlugin;
|
|
8
|
+
exports.getRoutePrefix = getRoutePrefix;
|
|
9
|
+
exports.httpError = httpError;
|
|
10
|
+
const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
|
|
11
|
+
const env_helper_1 = require("./env.helper");
|
|
12
|
+
function registerRoute(callback) {
|
|
13
|
+
return callback;
|
|
14
|
+
}
|
|
15
|
+
function registerPlugin(callback) {
|
|
16
|
+
return (0, fastify_plugin_1.default)(callback);
|
|
17
|
+
}
|
|
18
|
+
function getRoutePrefix() {
|
|
19
|
+
return (0, env_helper_1.getenv)('ROUTE_PREFIX', '');
|
|
20
|
+
}
|
|
21
|
+
/** This is handled in error.plugin.ts */
|
|
22
|
+
function httpError(message, statusCode = 500) {
|
|
23
|
+
const error = new Error(message);
|
|
24
|
+
error.statusCode = statusCode;
|
|
25
|
+
return error;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=fastify.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastify.helper.js","sourceRoot":"","sources":["../../helpers/fastify.helper.ts"],"names":[],"mappings":";;;;;AAiBA,sCAEC;AAED,wCAEC;AAED,wCAEC;AAGD,8BAKC;AA9BD,oEAA0C;AAE1C,6CAAqC;AAUrC,SAAgB,aAAa,CAAC,QAAqD;IAC/E,OAAO,QAAQ,CAAA;AACnB,CAAC;AAED,SAAgB,cAAc,CAAC,QAAqD;IAChF,OAAO,IAAA,wBAAa,EAAC,QAAQ,CAAC,CAAA;AAClC,CAAC;AAED,SAAgB,cAAc;IAC1B,OAAO,IAAA,mBAAM,EAAC,cAAc,EAAE,EAAE,CAAC,CAAA;AACrC,CAAC;AAED,yCAAyC;AACzC,SAAgB,SAAS,CAAC,OAAe,EAAE,aAAqB,GAAG;IAC/D,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAiB,CAAA;IAChD,KAAK,CAAC,UAAU,GAAG,UAAU,CAAA;IAE7B,OAAO,KAAK,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerDefault, RouteHandlerMethod } from 'fastify';
|
|
2
|
+
import { TClientReply, TClientRequest } from '../schemas/client.schema';
|
|
3
|
+
import { TConfigReply, TConfigRequest } from '../schemas/config.schema';
|
|
4
|
+
import { TPlayReply, TPlayRequest } from '../schemas/play.schema';
|
|
5
|
+
import { TValidateReply, TValidateRequest } from '../schemas/validate.schema';
|
|
6
|
+
export type RouteHandler<TRequest, TReply> = RouteHandlerMethod<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, {
|
|
7
|
+
Body: TRequest;
|
|
8
|
+
Reply: TReply;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class HandlersHelper<IHandlers extends {
|
|
11
|
+
[key: string]: {
|
|
12
|
+
request: any;
|
|
13
|
+
reply: any;
|
|
14
|
+
};
|
|
15
|
+
}> {
|
|
16
|
+
protected handlers: Map<string, RouteHandler<any, any>>;
|
|
17
|
+
register<TName extends keyof IHandlers>(name: TName, handler: RouteHandler<IHandlers[TName]['request'], IHandlers[TName]['reply']>): void;
|
|
18
|
+
get<TName extends keyof IHandlers>(name: TName): RouteHandler<IHandlers[TName]['request'], IHandlers[TName]['reply']>;
|
|
19
|
+
has<TName extends keyof IHandlers>(name: TName): boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const handlers: HandlersHelper<{
|
|
22
|
+
play: {
|
|
23
|
+
request: TPlayRequest;
|
|
24
|
+
reply: TPlayReply;
|
|
25
|
+
};
|
|
26
|
+
validate: {
|
|
27
|
+
request: TValidateRequest;
|
|
28
|
+
reply: TValidateReply;
|
|
29
|
+
};
|
|
30
|
+
config: {
|
|
31
|
+
request: TConfigRequest;
|
|
32
|
+
reply: TConfigReply;
|
|
33
|
+
};
|
|
34
|
+
client: {
|
|
35
|
+
request: TClientRequest;
|
|
36
|
+
reply: TClientReply;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
//# sourceMappingURL=handlers.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.helper.d.ts","sourceRoot":"","sources":["../../helpers/handlers.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,yBAAyB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,kBAAkB,EAC/F,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAG7E,MAAM,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI,kBAAkB,CAC/D,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,EACzB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAChC,CAAA;AAED,qBAAa,cAAc,CAAC,SAAS,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,CAAA;CAAE;IACzF,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAE,MAAM,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAY;IAEpE,QAAQ,CAAC,KAAK,SAAS,MAAM,SAAS,EAClC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IAMjF,GAAG,CAAC,KAAK,SAAS,MAAM,SAAS,EAAE,IAAI,EAAE,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IASrH,GAAG,CAAC,KAAK,SAAS,MAAM,SAAS,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO;CAI3D;AAED,eAAO,MAAM,QAAQ;UACT;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE;cACxC;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,KAAK,EAAE,cAAc,CAAA;KAAE;YACtD;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,YAAY,CAAA;KAAE;YAChD;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,YAAY,CAAA;KAAE;EAC1D,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handlers = exports.HandlersHelper = void 0;
|
|
4
|
+
const fastify_helper_1 = require("./fastify.helper");
|
|
5
|
+
class HandlersHelper {
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
register(name, handler) {
|
|
8
|
+
const handlerName = name;
|
|
9
|
+
this.handlers.set(handlerName, handler);
|
|
10
|
+
}
|
|
11
|
+
get(name) {
|
|
12
|
+
if (this.has(name)) {
|
|
13
|
+
const handlerName = name;
|
|
14
|
+
return this.handlers.get(handlerName);
|
|
15
|
+
}
|
|
16
|
+
throw (0, fastify_helper_1.httpError)(`Handler "${String(name)}" is not registered`);
|
|
17
|
+
}
|
|
18
|
+
has(name) {
|
|
19
|
+
const handlerName = name;
|
|
20
|
+
return this.handlers.has(handlerName);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.HandlersHelper = HandlersHelper;
|
|
24
|
+
exports.handlers = new HandlersHelper();
|
|
25
|
+
//# sourceMappingURL=handlers.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.helper.js","sourceRoot":"","sources":["../../helpers/handlers.helper.ts"],"names":[],"mappings":";;;AAQA,qDAA4C;AAS5C,MAAa,cAAc;IACb,QAAQ,GAAyC,IAAI,GAAG,EAAE,CAAA;IAEpE,QAAQ,CACJ,IAAW,EACX,OAA6E;QAE7E,MAAM,WAAW,GAAG,IAAc,CAAA;QAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;IAED,GAAG,CAAgC,IAAW;QAC1C,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjB,MAAM,WAAW,GAAG,IAAc,CAAA;YAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACzC,CAAC;QAED,MAAM,IAAA,0BAAS,EAAC,YAAY,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAClE,CAAC;IAED,GAAG,CAAgC,IAAW;QAC1C,MAAM,WAAW,GAAG,IAAc,CAAA;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACzC,CAAC;CACJ;AAxBD,wCAwBC;AAEY,QAAA,QAAQ,GAAG,IAAI,cAAc,EAKtC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FastifyLoggerOptions, RawServerBase } from 'fastify';
|
|
2
|
+
import { FastifyBaseLogger, PinoLoggerOptions } from 'fastify/types/logger';
|
|
3
|
+
import pino from 'pino';
|
|
4
|
+
export declare const loggerOptions: boolean | FastifyLoggerOptions<RawServerBase> & PinoLoggerOptions | FastifyBaseLogger;
|
|
5
|
+
export declare const logger: pino.Logger<never, boolean>;
|
|
6
|
+
//# sourceMappingURL=logger.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.helper.d.ts","sourceRoot":"","sources":["../../helpers/logger.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,IAAI,MAAM,MAAM,CAAA;AAIvB,eAAO,MAAM,aAAa,EAC1B,OAAO,GACP,oBAAoB,CAAC,aAAa,CAAC,GAAG,iBAAiB,GACvD,iBAUC,CAAA;AACD,eAAO,MAAM,MAAM,6BAAsB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logger = exports.loggerOptions = void 0;
|
|
7
|
+
const pino_1 = __importDefault(require("pino"));
|
|
8
|
+
const env_helper_1 = require("./env.helper");
|
|
9
|
+
exports.loggerOptions = {
|
|
10
|
+
level: (0, env_helper_1.getenv)('LOG_LEVEL', 'error'),
|
|
11
|
+
transport: {
|
|
12
|
+
target: 'pino-pretty',
|
|
13
|
+
options: {
|
|
14
|
+
translateTime: 'UTC:yyyy-mm-dd HH:MM:ss.l',
|
|
15
|
+
colorize: true,
|
|
16
|
+
singleLine: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
exports.logger = (0, pino_1.default)(exports.loggerOptions);
|
|
21
|
+
//# sourceMappingURL=logger.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.helper.js","sourceRoot":"","sources":["../../helpers/logger.helper.ts"],"names":[],"mappings":";;;;;;AAEA,gDAAuB;AAEvB,6CAAqC;AAExB,QAAA,aAAa,GAGN;IAChB,KAAK,EAAE,IAAA,mBAAM,EAAC,WAAW,EAAE,OAAO,CAAC;IACnC,SAAS,EAAE;QACP,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE;YACL,aAAa,EAAE,2BAA2B;YAC1C,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;SACnB;KACJ;CACJ,CAAA;AACY,QAAA,MAAM,GAAG,IAAA,cAAI,EAAC,qBAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkg-version.helper.d.ts","sourceRoot":"","sources":["../../helpers/pkg-version.helper.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAY1C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageVersion = getPackageVersion;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Resolve package.json from either compiled output (`dist/helpers/…`) or source (`helpers/…` under ts-jest).
|
|
8
|
+
*/
|
|
9
|
+
function getPackageVersion() {
|
|
10
|
+
const candidates = [
|
|
11
|
+
(0, path_1.join)(__dirname, '..', 'package.json'),
|
|
12
|
+
(0, path_1.join)(__dirname, '..', '..', 'package.json'),
|
|
13
|
+
];
|
|
14
|
+
for (const pkgPath of candidates) {
|
|
15
|
+
if ((0, fs_1.existsSync)(pkgPath)) {
|
|
16
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf-8'));
|
|
17
|
+
return pkg.version ?? '0.0.0';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return '0.0.0';
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=pkg-version.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkg-version.helper.js","sourceRoot":"","sources":["../../helpers/pkg-version.helper.ts"],"names":[],"mappings":";;AAMA,8CAYC;AAlBD,2BAA6C;AAC7C,+BAA2B;AAE3B;;GAEG;AACH,SAAgB,iBAAiB;IAC7B,MAAM,UAAU,GAAG;QACf,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC;QACrC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC;KAC9C,CAAA;IACD,KAAK,MAAM,OAAO,IAAI,UAAU,EAAE,CAAC;QAC/B,IAAI,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAyB,CAAA;YAC9E,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAA;QACjC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Simple random */
|
|
2
|
+
export declare function random(range: number): number;
|
|
3
|
+
/** Random element of array */
|
|
4
|
+
export declare function randomOf<T = number>(arr: Array<T>): T;
|
|
5
|
+
/** Get value by distribution */
|
|
6
|
+
export declare function getByChance(distArray: Array<number> | Uint8Array): number;
|
|
7
|
+
//# sourceMappingURL=random.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.helper.d.ts","sourceRoot":"","sources":["../../helpers/random.helper.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,8BAA8B;AAC9B,wBAAgB,QAAQ,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,KAAK,CAAE,CAAC,CAAC,GAAG,CAAC,CAEtD;AAED,gCAAgC;AAChC,wBAAgB,WAAW,CAAC,SAAS,EAAE,KAAK,CAAE,MAAM,CAAC,GAAG,UAAU,GAAG,MAAM,CAE1E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.random = random;
|
|
4
|
+
exports.randomOf = randomOf;
|
|
5
|
+
exports.getByChance = getByChance;
|
|
6
|
+
/** Simple random */
|
|
7
|
+
function random(range) {
|
|
8
|
+
return Math.floor(Math.random() * 2000000000) % range;
|
|
9
|
+
}
|
|
10
|
+
/** Random element of array */
|
|
11
|
+
function randomOf(arr) {
|
|
12
|
+
return arr[random(arr.length)];
|
|
13
|
+
}
|
|
14
|
+
/** Get value by distribution */
|
|
15
|
+
function getByChance(distArray) {
|
|
16
|
+
return distArray[random(distArray.length)];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=random.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.helper.js","sourceRoot":"","sources":["../../helpers/random.helper.ts"],"names":[],"mappings":";;AACA,wBAEC;AAGD,4BAEC;AAGD,kCAEC;AAbD,oBAAoB;AACpB,SAAgB,MAAM,CAAC,KAAa;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,KAAK,CAAA;AACzD,CAAC;AAED,8BAA8B;AAC9B,SAAgB,QAAQ,CAAa,GAAc;IAC/C,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AAClC,CAAC;AAED,gCAAgC;AAChC,SAAgB,WAAW,CAAC,SAAsC;IAC9D,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema, ValidateFunction } from 'ajv';
|
|
2
|
+
import { FastifyTypebox } from './fastify.helper';
|
|
3
|
+
export declare function testBuild(): FastifyTypebox;
|
|
4
|
+
export declare const testHeaders: {
|
|
5
|
+
"x-api-key": string;
|
|
6
|
+
};
|
|
7
|
+
export declare function validator(schema: Schema): ValidateFunction;
|
|
8
|
+
export declare function checkSchemaPropertyDescriptions(props: Record<string, any>): void;
|
|
9
|
+
//# sourceMappingURL=tests.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tests.helper.d.ts","sourceRoot":"","sources":["../../helpers/tests.helper.ts"],"names":[],"mappings":"AACA,OAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,wBAAgB,SAAS,IAAI,cAAc,CAQ1C;AAED,eAAO,MAAM,WAAW;;CAEvB,CAAA;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAK1D;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAgBzE"}
|