Controller dev

  1. Hub server
  2. Install hub
  3. Run hub
  4. Adding a casino
    1. Method 1: Dashboard
    2. Method 2: CLI
    3. What is this for?

So, you want to build a game server that integrates with MoneyPot.com?

Hub server

MoneyPot game servers are built with our official Node.js @moneypot/hub game server.

Hub handles the complexities of casino<->game communication and data synchronization so that you can focus on building your game.

A flurry of hub features:

  • Extensible Postgres schema
  • Extensible GraphQL API built on top of Postgraphile v5
  • Comes out of the box with a generic makeOutcomeBet endpoint
  • One hub server can handle multiple games (experiences) and even multiple casinos
  • Websocket subscription API for balance updates
  • Multi-tenant across (casino_id, experience_id, user_id)
  • Admin dashboard
  • Automatic deposit (put) and withdrawal (take) processing

Install hub

The hub server is distributed as a Node.js module at https://www.npmjs.com/package/@moneypot/hub.

npm install @moneypot/hub

Run hub

Other sections of this manual will explain how to extend the hub server with your own functionality, but this is the hello world.

Check out the template controller for a complete example.

import {
  defaultPlugins,
  type ServerOptions,
  startAndListen,
} from "@moneypot/hub";

const options: ServerOptions = {
  extraPgSchemas: ["app"],
  plugins: [...defaultPlugins],
  // ...
};

startAndListen(options).then(({ port }) => {
  console.log(`Server is listening on ${port}`);
});

Adding a casino

The first thing you need to do when starting a hub server is to tell it about the MoneyPot.com casino and give it your controller’s API key.

First, create a controller at https://moneypot.com/me/developer/controllers and generate an API key for it.

Method 1: Dashboard

The simplest way to add a casino is to use the hub dashboard.

Once you authenticate, click “Add casino” and fill out the form:

  • Name: moneypot.com
  • Base URL: https://moneypot.com
  • GraphQL URL: https://moneypot.com/graphql
  • API Key: The API key you generated for your controller

Method 2: CLI

You can also use an add-casino CLI command available in the project root of your Node.js project if it has @moneypot/hub as a dependency.

npx add-casino \
  --name "moneypot.com" \
  --base_url https://moneypot.com \
  --graphql_url https://moneypot.com/graphql \
  --api_key <UUID>

If you want to add a casino to a remote database, you can specify the SUPERUSER_DATABASE_URL environment variable:

SUPERUSER_DATABASE_URL=postgres://user:password@host:port/my-db npx add-casino ...

What is this for?

MoneyPot.com passes the experience frontend a userToken that is used to identify the player.

The experience frontend then calls hub’s GraphQL API hubAuthenticate(input: { casinoBaseUrl: "https://moneypot.com", userToken: "..." }) to authenticate the player.

The hub server looks up the casino and controller API key in its hub.casino table with the casinoBaseUrl before authenticating the player.

If you haven’t configured a casino, you’ll see an error like “Casino not found”.


Table of contents