135 lines
2.1 KiB
Markdown
135 lines
2.1 KiB
Markdown
# Peddlers of Ketran
|
|
|
|
## Building
|
|
|
|
### Native
|
|
|
|
#### Prerequisites
|
|
|
|
```bash
|
|
sudo apt-get install -y nodejs npm python
|
|
sudo -E npm install --global npm@latest
|
|
```
|
|
|
|
### In container
|
|
|
|
```bash
|
|
```
|
|
|
|
# Architecture
|
|
|
|
```plantuml
|
|
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
|
|
|
|
```json
|
|
{}
|
|
```
|
|
|
|
### Response
|
|
|
|
```json
|
|
{
|
|
gameId: id
|
|
gameState: {
|
|
tiles: []
|
|
}
|
|
}
|
|
```
|
|
|
|
# Configuring / installing
|
|
|
|
## Build
|
|
|
|
```bash
|
|
git clone git.ketrenos.com:jketreno/peddlers-of-ketran.git
|
|
npm install
|
|
cd server
|
|
npm install
|
|
cd ..
|
|
npm run-script build
|
|
npm run-script backend
|
|
```
|
|
|
|
## Install
|
|
```bash
|
|
sudo cp ketr.ketran /etc/logrotate.d/
|
|
sudo cp ketr.ketran.service /etc/systemd/system/
|
|
sudo systemctl daemon-reload
|
|
```
|
|
|
|
Install the following into your nginx server configuration:
|
|
|
|
```nginx
|
|
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;
|
|
}
|
|
|
|
location /ketr.ketran {
|
|
alias /var/www/html/peddlers-of-ketran;
|
|
}
|
|
```
|
|
|
|
Add security tokens in ketr.ketran/config/local.json:
|
|
|
|
```bash
|
|
cat << EOF > config/local.json
|
|
{
|
|
"tokens": [ {
|
|
"$(whoami)": "$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;)"
|
|
} ]
|
|
}
|
|
EOF
|
|
```
|
|
|
|
## Launch
|
|
|
|
```bash
|
|
sudo systemctl start ketr.ketran
|
|
```
|
|
|
|
## To test
|
|
|
|
### New game
|
|
```bash
|
|
curl -k -s -X POST http://localhost:8930/ketr.ketran/api/v1/games/
|
|
```
|
|
|
|
### Game status
|
|
|
|
```bash
|
|
curl -k -s -X GET http://localhost:8930/ketr.ketran/api/v1/games/:id
|
|
```
|