Skip to content

Server & Database Setup

ReactX edited this page Dec 21, 2024 · 14 revisions

Tutorial

IMAGE ALT TEXT HERE

Server Setup

We are running a Koa application using Node.js with TypeScript.

  1. Open a terminal inside the server directory: cd server

  1. Install the required Node dependencies: npm i

  1. Compile and run the application: npm run serve

If everything runs fine (without error), you can open the admin dashboard at http://localhost:3001

The default configuration will work fine but should you wish to modify it, the environment variables are located in the .env file.


Database Setup

For our current database implementation, we have adopted MariaDB with MikroORM. We have chosen to migrate to this database for faster concurrency and transactions.


  1. To begin, download and install XAMPP for your operating system.

  2. Next, start both Apache and MySQL, then click on Admin for MySQL, this should launch phpMyAdmin in your web browser.

  3. Click on 'New' in the top-left, and for your Database name put in bym. Then click the 'Create' button.

  4. Next, run the following commands within your ./server directory of the project:

npm run db:init

This command should generate a database folder with a Migration and snapshot file, located at server/src/database


DBMS Setup

  1. Download a SQL editor and database management tool of your preference, we like to use Beekeeper Studio.

    • New Connection > Select a connection type > MariaDB

    • Input the following credentials:

      Connection Type: MariaDB

      Connection Mode: Host & Port

      Host: localhost

      User: root

      Password: (Please leave this blank)

      Default Database: bym

    • You can provide a 'Connection Name' and you should now be able to connect successfully.

    • Once connected, you should see the tables on the left-hand side. Right click on a table > View Data. If you have not run the game yet at this point, it should have no data.

    • Finally, start the server, run the game and once loaded, refresh the database to see populated data within the tables, example:

image


Redis Setup

We are using Redis on our server to store user tokens, for efficient read/writes.

  • To begin, download redis-windows, and select the cygwin.zip one (not the service)

  • Once downloaded, extract the contents to a folder of your choice, preferably your Desktop.

  • Open the folder and double-click (run) the redis-server.exe file. This will run the Redis service in the background.

image