Package: tuicubserver
Back-endfortuicub- online multiplayer board game in your terminal.API Documentation·Events DocumentationFeaturesFully typed code (PEP-484),Testable, clean layered architecture,100% tests coverage,All public interfaces documented withGoogle style docstrings,Detailed API documentation using theOpenAPI 3.1.0specification.OverviewTheClientconnects to theEvents Serverto receive real-time notifications about events that occur in the user's game or gameroom,TheClientqueries and issues commands to theAPI Servervia REST API,TheAPI Servernotifies theMessagingabout theClient's actions, such as ending a turn,TheMessagingthen notifies theEvents Serverthat an event has occured and it needs to be sent to affectedClients,TheEvents Serversends the event that occurred to all affectedClients.InstallationUsingpipTuicubserver is available astuicubserveron PyPI:pipinstalltuicubserverManuallyStart by cloning the repository:gitclonehttps://github.com/tom-bartk/tuicub-server.gitcdtuicub-serverThen, install the project's dependencies:python-mpipinstall-e.You can now launch the server using the following commands:$python-msrc.tuicubserver

Usage:python-msrc.tuicubserver[OPTIONS]COMMAND[ARGS]...

Options:--helpShowthismessageandexit.

Commands:apiStarttheAPIserver.eventsStarttheeventsandmessagesserver.ConfigurationPrerequisitesAPostgreSQLdatabase is needed for persistence. Some oftuicub's models utilize theARRAYdata type, hence the need for the PostgreSQL backend.config.tomlConfiguration is done via atomlfile with a following structure and default values:[db]# Connection string to the database.url="postgresql+psycopg2://postgres:postgres@localhost:5432/tuicub"[logging]# Path to a file to write logs to.logfile="/tmp/tuicubserver.log"[messages]# Host of the messages server to connect to.host="api.tuicub.com"# Port of the messages server.port=23433# Secret to use when sending messages.secret="changeme"[events]# Secret to use when authorizing disconnect callbacks from the events server.secret="changeme"To use a custom configuration, set theTUICUBSERV_CONFenvironment variable to the path of your config file.For example:TUICUBSERV_CONF=~/mytuicub/myconfig.tomltuicubserverapiIf theTUICUBSERV_CONFenvironment variable is not set or the file does not exist, the app will try to read aconfig.tomlfile from the current working directory.LaunchingAPI ServerThetuicubserver apicommandUse theapicommand to start the API server, for example:TUICUBSERV_CONF=./config.tomltuicubserverapi--host0.0.0.0--port8080This will run the underlyingFlaskapplication on all available interfaces and port 8080 using theWerkzeug's development server.[!WARNING]
This method is suitable only for local use. For production deployment, follow theUsing a WSGI HTTP serverinstructions below.Using a WSGI HTTP serverSince the API server is a WSGI application (PEP-3333), you can use any WSGI HTTP server of your choice. The application factory namedcreate_appis defined in thesrc.tuicubserver.tuicubservermodule.To start the api server usinggunicornon all interfaces and port 8080 run:TUICUBSERV_CONF=./config.tomlgunicorn\--bind0.0.0.0:8080\"src.tuicubserver.tuicubserver:create_app()"Events ServerBoth the Messaging and the Events Server run in the same process. To start it, use thetuicubserver eventscommand:Usage: tuicubserver events [OPTIONS]

  Start the events and messages server.

Options:
  --events-port PORT    Port to bind events server to.  [default: 23432]
  --events-host HOST    Host to bind events server to.  [default: 0.0.0.0]
  --messages-port PORT  Port to bind messages server to.  [default: 23433]
  --messages-host HOST  Host to bind messages server to.  [default: 0.0.0.0]
  --api-url URL         Base URL of the API for disconnect callbacks.
                        [default: https://api.tuicub.com]
  --help                Show this message and exit.Following example uses the default host and ports, and a custom API Server:TUICUBSERV_CONF=./config.tomltuicubserverevents--api-urlhttp://localhost:8080DocumentationAPI DocsVisit theAPI Documentationfor a detailed description of all API endpoints.ScreenshotEvents Docstuicubgameplay is driven by asynchronous events delivered over TCP sockets.Every event is fully documented in theEvents Documentation.ScreenshotLicenseCopyright (C) 2023 tombartk 

This program is free software: you can redistribute it and/or modify it under the terms
of the GNU Affero General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.
If not, see https://www.gnu.org/licenses/.