npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

turngame

v1.2.4

Published

Ganomede turngame micro service

Downloads

4

Readme

Turn-Game

Manage a turn based game session.

Relations

The turn-game module will:

  • Manage in-progress games in the redis_games redis database.
  • Perform moves requested by clients using rules-api services, update redis_games.
  • Use the redis_auth database to check requester identity.

Configuration

  • RULES_PORT_8080_TCP_ADDR - IP of the rules service
  • RULES_PORT_8080_TCP_PORT - Port of the rules service
  • CHAT_PORT_8080_TCP_ADDR - IP of the chat service (optional)
  • CHAT_PORT_8080_TCP_PORT - Port of the chat service (optional)
  • NOTIFICATIONS_PORT_8080_TCP_ADDR - IP of the notifications service
  • NOTIFICATIONS_PORT_8080_TCP_PORT - Port of the notifications service
  • API_SECRET - Secret key used to send notifications
  • REDIS_AUTH_PORT_6379_TCP_ADDR - IP of the AuthDB redis
  • REDIS_AUTH_PORT_6379_TCP_PORT - Port of the AuthDB redis
  • REDIS_GAMES_PORT_6379_TCP_ADDR - IP of the games redis
  • REDIS_GAMES_PORT_6379_TCP_PORT - Port of the games redis

API

All requests made to the turngame API require an auth token, passed in the request URL.

Single Game [/turngame/v1/auth/:token/games/:id]

+ Parameters
    + token (string) ... User authentication token
    + id (string) ... ID of the game

Retrieve a game state [GET]

response [200] OK

{
    "id": "ab12345789",
    "type": "triominos/v1",
    "players": [ "some_username_1", "some_username_2" ],
    "turn": "some_username_1",
    "status": "active",
    "gameData": { ... }
}

Possible status:

  • inactive
  • active
  • gameover

Create a game [POST]

Use the appropriate rules-api service to initiate a new game.

body (application/json)

{
    "type": "triominos/v1",
    "players": [ "some_username_1", "some_username_2" ],
    "gameConfig": {
        ... game specific data to be passed to the rules-api ...
    }
}

response [200] OK

{
    "id": "1234",
    "type": "triominos/v1",
    "players": [ "some_username", "other_username" ],
    "turn": "some_username",
    "status": "inactive",
    "gameData": {
        ... game specific data ...
    }
}

Moves Collection [/turngame/v1/auth/:token/games/:id/moves]

+ Parameters
    + token (string) ... Authentication token
    + id (string) ... ID of the game

Add a move to a game [POST]

Add a move, optionally trigger a chat system event (if "chatEvent" is provided).

body (application/json)

{
    "moveData": { ... },
    "chatEvent": "pass"
}

response [200] OK

{
    "id": "string",
    "type": "triominos/v1",
    "players": [ "some_username", "other_username" ],
    "turn": "other_username",
    "status": "active",
    "gameData": {
        ... game specific data ...
    },
    "moveResult" {
        ... game specific data ...
    }
}

response [400] Bad Request

{
    "code": "InvalidPosition"
}

List of codes will be application dependent, as returned by the rules-api

List moves made on the given game [GET]

response [200] OK

[
    {
        "player": "some_username",
        "move": { ... }
    },
    {
        "player": "other_username",
        "move": { ... }
    },
    {
        "player": "some_username",
        "move": { ... }
    }
]