@moneypot/hub
v1.20.6
Published
Official MoneyPot hub server
Readme
@moneypot/hub
@moneypot/hub is our official GraphQL game server for building games for MoneyPot.com.
- Extend it with custom tables and game logic.
- Give it an api key for each controller you've registered on each casino.
- It will automatically sync users, their balances, deposits, and withdrawals.
Example implementations:
- https://github.com/moneypot/controller-template/: An template hub server that comes with an example of a custom game implementation.
Manual
View our docs: https://docs.moneypot.com
Install
$ pnpm install @moneypot/hubUsage
import {
type ServerOptions,
defaultPlugins,
startAndListen,
MakeOutcomeBetPlugin,
} from "@moneypot/hub";
import path from "path";
const options: ServerOptions = {
// PostgreSQL schemas to expose to the GraphQL API
// This allows your application-specific tables to be accessible through GraphQL
extraPgSchemas: ["app"],
plugins: [
// These are required for the hub server to function
...defaultPlugins,
// Add your custom plugins here to extend server functionality
MakeOutcomeBetPlugin({
houseEdge: 0.01,
}),
],
// File path where the generated GraphQL schema definition will be saved
exportSchemaSDLPath: path.join(import.meta.dirname, "../schema.graphql"),
// Optional: Directory containing migration files for your database
// When enabled, the server will automatically apply pending migrations on startup
userDatabaseMigrationsPath: path.join(
import.meta.dirname,
"../automigrations",
),
};
startAndListen(options)
.then(({ port }) => {
console.log(`Listening on ${port}`);
})
.catch(console.error);Dashboard
When the server is running, visit its admin dashboard at the /dashboard route.
You'll need an api key from your hub database:
insert into hub.api_key default values returning key;Changelog
You should always keep your hub server up to date as soon as possible. Never install an old, intermediate version: it may leave you without an automatic upgrade path.
1.20.x
Adds liability tracking for multistage games (mines, crash, etc.) that lock up bankroll before resolution.
- (DB migration) New
hub.bankroll.liabilitycolumn - (DB migration) New
hub.liabilitytable (each row ties to a game row likeapp.mines_game) dbCreateLiability()to reserve bankroll when a game starts,dbResolveLiability()to release it when it ends- Available bankroll =
amount - liability - Type renames:
DbBalance→DbPlayerBalance,DbBankroll→DbHouseBankroll dbLockedHouseBankroll()now returnsDbLockedHouseBankrollWithAvailable(hasavailablefield)
1.19.x
- All of hub's internal graphql-schema-modifying plugins have been moved to hub's set of required plugins.
- Added
FAILEDtake request auto-handling. - Exposed a
@moneypot/hub/testmodule for end-user server testing.
1.18.x
MakeOutcomeBetPluginreplaced byHubGameConfigPlugin({ outcomeBetConfigs, customGameConfigs })- Added graphql query
hubRiskLimits(gameKinds: [DICE])to get risk limits for the game kinds configured inHubGameConfigPlugin.- This lets experiences display the max payout for each kind of bet.
1.17.x
- Postgres transactions now default to read committed (postgres default)
- Added cli script
npx db-migrate <userMigrationDirectory>to run hub and user db migrations onSUPERUSER_DATABASE_URL.- Note: hub still runs any non-run migrations on server start
1.16.x
- Added a simple built-in chat system.
- You can opt-out of the chat system by passing
startAndListen({ ..., enableChat: false }).
1.15.x
- Added a "playground" casino (
hub.casino.is_playground = true) that lets skin devs create ephemeral sessions for testing. - Added
hubCreatePlaygroundSessionmutation to create a playground session.- It's a drop-in replacement for
hubAuthenticate({ userToken, baseCasinoUrl })when you're testing your experience outside of the MoneyPot.com iframe (thus you don't have a userToken).
- It's a drop-in replacement for
- You can opt-out of allowing playground sessions by passing
startAndListen({ ..., enablePlayground: false }), but remember that the objective of this system is to make it easier for developers to build experience frontends that bet against your server.
1.14.x
- Added
preimageHashfield toHubHashChainto expose the preimage hash for a hash chain if it's revealed.
1.13.x
- Added
hubRevealHashChainmutation to generate a preimage hash for the chain and mark it as inactive.
1.12.x
- Added
hub.audit_logtable to track balance and bankroll changes. - Removed built-in hub faucet and old withdraw system.
1.11.x
- Migrated database-related "globals" into a
ServerContextobject.- Changed
configureApp(app: ExpressServer)toconfigureApp(args: { app: ExpressServer, superuserPool: pg.Pool }) - In a postgraphile plugin, you can access the superuser database pool via
const $superuserPool = context().get("superuserPool");
- Changed
1.9.x
- Added a required risk policy to
makeOutcomeBetand a reusablevalidateRiskfunction that can be used in custom bet plugins / endpoints to decide how much bankroll you want to risk on a bet.
1.8.x
- Added pino for logging.
- Added
LOG_LEVELenvironment variable to set the logging level. (default:info) - Added
LOG_PRETTYenvironment variable to force enable/disable pretty logging (requiresnpm install pino-pretty). - Exposed
@moneypot/hub/logger. Example:import { logger } from "@moneypot/hub/logger";
1.7.x
Updated Hub to handle breaking changes in moneypot-server GraphQL transfer API.
1.6.x
Hub now maintains a websocket connection to the casino API so that it can respond immediately to puts and takes.
1.5.x
Migrated to Postgraphile beta.42 which has new plugin and polymorphism systems:
Read more:
- https://www.graphile.org/news/20250607-last-epic-solved/
- https://grafast.org/grafast/polymorphism
