1
0
James Ketrenos 4a6351ccd1 Added client launch readme
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
2022-01-26 16:58:16 -08:00
2022-01-26 16:58:16 -08:00
2020-04-25 13:38:54 -07:00
2022-01-03 21:13:47 -08:00
2022-01-26 13:05:43 -08:00
2022-01-26 13:05:43 -08:00
2022-01-02 22:27:58 -08:00
2022-01-26 13:05:43 -08:00

Peddlers of Ketran

This project consists of both the front-end and back-end game API server.

The front-end is launched from the 'client' directory in development mode via 'npm start'. In production, you build it via 'npm build' and deploy the public front-end.

The back-end is launched out of the 'server' directory via 'npm start' and will bind to the default port 8930.

If you change the default port of the REST API server, you will need to change client/package.json's "proxy" value to reflect the new port change.

NOTE:

Board.js currently hard codes assetsPath and gamesPath to be absolute as the dynamic router and resource / asset loading isn't working correctly.

Building

Native

Prerequisites

sudo apt-get install -y nodejs npm python
sudo -E npm install --global npm@latest

In container

Architecture

skinparam componentStyle rectangle

component "Server" as server
component "Resources" as res
component "Client" as client
component "Game" as game
component "Player" as player

package "Game" as game {
  component Players as players
}

server <-> resource : serves to client
client <-> server
player <-> client
players -r-> player
server -> game

Ketr.Ketran REST API

POST /api/v1/game

Request

{}

Response

{
  gameId: id
  gameState: {
    tiles: []
  }
}

Configuring / installing

Build

git clone git.ketrenos.com:jketreno/peddlers-of-ketran.git
cd server
npm install
npm start &
cd ../client
npm install
npm start

Install

export BASEPATH=${PWD}
# Ensure sudo has password ready
sudo -l 
envsubst BASEPATH < install/ketr.ketran | sudo tee /etc/logrotate.d/ketr.ketran
envsubst BASEPATH < install/ketr.ketran.service | sudo tee /etc/systemd/system/ketr.ketran.service
sudo systemctl daemon-reload

Install the following into your nginx server configuration:

  location /ketr.ketran {
    alias ${BASEPATH};
  }

  location ~ /ketr.ketran/api/.* {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass_header Set-Cookie;
    proxy_pass_header P3P;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass http://localhost:8930;
  }

Add security tokens in ketr.ketran/config/local.json:

cat << EOF > config/local.json
{
  "tokens": [ {
    "$(whoami)": "$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;)"
  } ]
}
EOF

Launch

sudo systemctl start ketr.ketran

To test

New game

curl -k -s -X POST http://localhost:8930/ketr.ketran/api/v1/games/

Game status

curl -k -s -X GET http://localhost:8930/ketr.ketran/api/v1/games/:id
Description
No description provided
Readme 194 MiB
Languages
TypeScript 86.5%
JavaScript 5.8%
CSS 5.7%
Shell 0.9%
Dockerfile 0.6%
Other 0.5%