The server of Scratch Bonanza.
1. Install the project dependencies:
yarn
2. Start the server:
yarn start
3. Start the frontend, following the instructions in the Scratch Bonanza repository.
The server offers a single API endpoint that returns an array of four values chosen randomly.
Given the significance of security in the online gaming industry, where safeguarding fairness and integrity is paramount, to achieve secure random number generation, the server relies on the Crypto module of Node.js. It is specifically designed to utilize cryptographic algorithms and system-level entropy sources, ensuring the production of random output that is suitable for cryptographic operations and resistant to various attacks.
Since it is possible for Node.js to be built without including support for the node:crypto
module, it is checked whether the module is available. If that is not the case, the service will fall back to using Math.random() for generating random numbers.
The values and the probability of occurrence are the following:
Value | Probability |
---|---|
0 | 50% |
1 | 30% |
10 | 15% |
100 | 4% |
1000 | 1% |
These are the probabilities of some scenarios to occur:
Scenario | Probability |
---|---|
Get at least 1 coin | 39.8332% |
Get four 0s | 6.25% |
Get four 1s | 0.81% |
Get four 10s | 0.050625% |
Get four 100s | 0.000256% |
Get four 1000s | 0.000001% |
The core technologies of Scratch Bonanza Server are Node and CORS. The following libraries and tools are used:
Name | License | Description |
---|---|---|
TypeScript | MIT | A strongly typed programming language that builds on JavaScript |
Node.js | MIT | Cross-platform JavaScript runtime environment. |
Express | MIT | Backend framework for building RESTful APIs with Node.js |
CORS | MIT | Node.js CORS middleware |
Copyright (c) 2023 Michael Kolesidis
Licensed under the GNU Affero General Public License v3.0.