105 lines
1.6 KiB
Markdown
105 lines
1.6 KiB
Markdown
# Peddlers of Ketran
|
|
|
|
## Building
|
|
|
|
### Native
|
|
|
|
```bash
|
|
sudo apt-get install nodejs npm
|
|
sudo -E npm install --global npm@latest
|
|
```
|
|
|
|
### In container
|
|
|
|
```bash
|
|
|
|
```
|
|
|
|
# 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
|
|
cd server
|
|
npm install
|
|
```
|
|
|
|
## 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;
|
|
}
|
|
```
|
|
|
|
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:8911/ketr.ketran/api/v1/games/
|
|
```
|
|
|
|
### Game status
|
|
|
|
```bash
|
|
curl -k -s -X GET http://localhost:8911/ketr.ketran/api/v1/games/:id
|
|
```
|