{"id":21025575,"url":"https://github.com/robertcorponoi/gameguard","last_synced_at":"2025-06-12T14:32:20.259Z","repository":{"id":56405961,"uuid":"215665564","full_name":"robertcorponoi/gameguard","owner":"robertcorponoi","description":"GameGuard is a NodeJS game server that can be used to manage the players connecting to your game, manage rooms and the players in them, and more.","archived":false,"fork":false,"pushed_at":"2020-11-09T22:20:44.000Z","size":330,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-10T17:01:07.107Z","etag":null,"topics":["game-server","nodejs","websocket"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertcorponoi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-16T23:55:33.000Z","updated_at":"2022-11-07T11:33:49.000Z","dependencies_parsed_at":"2022-08-15T18:10:16.438Z","dependency_job_id":null,"html_url":"https://github.com/robertcorponoi/gameguard","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/robertcorponoi/gameguard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertcorponoi%2Fgameguard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertcorponoi%2Fgameguard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertcorponoi%2Fgameguard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertcorponoi%2Fgameguard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertcorponoi","download_url":"https://codeload.github.com/robertcorponoi/gameguard/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertcorponoi%2Fgameguard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259482538,"owners_count":22864770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game-server","nodejs","websocket"],"created_at":"2024-11-19T11:34:31.999Z","updated_at":"2025-06-12T14:32:20.235Z","avatar_url":"https://github.com/robertcorponoi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# GameGuard\n\nGameGuard is a NodeJS game server that can be used to manage the players connecting to your game, manage rooms and the players in them, and more.\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n  [![NPM version](https://img.shields.io/npm/v/gameguard.svg?style=flat)](https://www.npmjs.com/package/gameguard)\n  [![Known Vulnerabilities](https://snyk.io/test/github/robertcorponoi/gameguard/badge.svg)](https://snyk.io/test/github/robertcorponoi/gameguard)\n  ![npm](https://img.shields.io/npm/dt/gameguard)\n  [![NPM downloads](https://img.shields.io/npm/dm/gameguard.svg?style=flat)](https://www.npmjs.com/package/gameguard)\n  \u003ca href=\"https://badge.fury.io/js/gameguard\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/robertcorponoi/gameguard.svg\" alt=\"issues\" height=\"18\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://badge.fury.io/js/gameguard\"\u003e\u003cimg src=\"https://img.shields.io/github/license/robertcorponoi/gameguard.svg\" alt=\"license\" height=\"18\"\u003e\u003c/a\u003e\n  [![Gitter](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/robertcorponoi)\n\n\u003c/div\u003e\n\n**Note:** This is the post 1.0.0 version of GameGuard that has lots of breaking changes from the last version due to major simplification. All of the previous features still exist but the API has changed to be more simple and streamlined. GameGuard can now be used on it's own but it has been simplified in order to be able to be extended further to suit your needs.\n\n**Note About Logging:** For now, GameGuard has no logging capability. I've gone back and forth about implementing logging but I've found it to be so customizable it would be much easier for the end user to implement using signals but if there's enough requests then logging can be implemented to be a core part of GameGuard.\n\n**Table of Contents**\n\n- [Install](#install)\n- [Initialization](#initialization)\n- [Operation](#operation)\n- [Docs](#docs)\n  - [Database](#database)\n  - [Players](#players)\n  - [Rooms](#rooms)\n  - [Global](#global)\n- [Tests](#tests)\n\n## **Install**\n\nTo install GameGuard you need the server side package (this one) and then a client-side package. Currently only [gameguard-client](https://github.com/robertcorponoi/gameguard-client) is supported but in the future there will be guides on creating your own client side solution to communicate with the GameGuard server.\n\nTo install GameGuard you can use:\n\n```bash\n$ npm install gameguard\n```\n\nand if you need gameguard-client, you can use:\n\n```bash\n$ npm install gameguard-client\n```\n\n**Note:** The documentation for gameguard-client will not be covered here but you can head over to the [gameguard-client documentation](https://github.com/robertcorponoi/gameguard-client#README.md) for client side usage.\n\n## **Initialization**\n\nTo initialize GameGuard, you have to initialize it with a reference to a http or https server and an optional set of options.\n\n| param                           | type        | description                                                                    | default                   |\n|---------------------------------|-------------|--------------------------------------------------------------------------------|---------------------------|\n| server                          | http.Server | A reference to the http server instance to bind to.                            |                           |\n| options                         | Object      |                                                                                |                           |\n| options.heartbeatInterval       | number      | The interval at which each player is pinged, in milliseconds.                  | 30000                     |\n| options.latencyCheckInterval    | number      | The interval at which each player's latency is calculated, in milliseconds.    | 5000                      |\n| options.maxLatency              | number      | The maximum latency, in milliseconds, the player can have before being kicked. | 300                       |\n| options.mongodbConnectionString | string      | The connection string to use to connect to mongodb.                            | mongodb://localhost:27017 |\n\n**Example:**\n\nA basic example of initializing GameGuard this with my personal favorite http server, fastify, is as follows:\n\n```js\n'use strict'\n\nconst path = require('path');\nconst fastify = require('fastify')({ logger: true });\n\nconst GameGuard = require('gameguard');\n\nconst gg = new GameGuard(fastify.server);\n\nfastify.listen(3000, (err, address) =\u003e {\n  if (err) throw err;\n\n  fastify.log.info(`server listening on ${address}`);\n});\n```\n\nHere's an example of initializaing GamGuard with options:\n\n```js\n'use strict'\n\nconst path = require('path');\nconst fastify = require('fastify')({ logger: false });\nconst GameGuard = require('gameguard');\n\n// Set the GameGuard server to use a latency check interval of 1000ms.\nconst gg = new GameGuard(fastify.server, { latencyCheckInterval: 1000 });\n\n// Have the server listen on port 3000.\nfastify.listen(3000, (err, address) =\u003e {\n    if (err) throw err;\n    console.log(`Listening on port 3000`);\n});\n```\n\nNotice how we pass fastify's server instance to GameGuard so that GameGuard can use it to communicate with the client.\n\nLet's also take a look how we can accomplish the same thing we did above but with express:\n\n```js\n'use strict'\n\nconst path = require('path');\nconst express = require('express');\nconst GameGuard = require('gameguard');\n\nconst app = express();\n\n// Have the server listen on port 3000.\nconst server = app.listen(3000, () =\u003e console.log('Listening on port 3000'));\n\n// Set the GameGuard server to use a latency check interval of 1000ms.\nconst gg = new GameGuard(server, { latencyCheckInterval: 1000 });\n```\n\n## **Operation**\n\nNow let's talk about the operation of GameGuard:\n\n1. The GameGuard server instance is created with a http server instance.\n\n2. Now, the GameGuard server waits for a WebSocket connection from a page using the GameGuard client and in specific it waits for the client to send a message that contains the id of the player that connected.\n\n3. Before the client becomes a player, the GameGuard server checks to see if the id of that client corresponds to a player in the database that is banned and if so their connection gets reject. Otherwise, the client is accepted and their player profile is created locally and updated in the database.\n\n4. Everything is set up now. The player can be kicked, banned, messaged, or put into rooms.\n\n## **Docs**\n\nSince GameGuard is not a linear app and it's hard to go in order with what to document, we'll just go over the general aspect of each part of GameGuard and then link to the documentation for that module that goes in detail about it.\n\n### **Database**\n\nThe GameGuard server uses the MongoDB to manage players with the mongoose package to manage the schemas and other operations. The database connection info has a default value of `mongodb://localhost:27017/gameguard` but you can configure the connection credentials in a `.env` file with a sample connection file provided as `.env.sample`. \n\nCheck out the [database documentation](docs/database.md) for more specific database operations.\n\n### **Players**\n\nAt it's core, GameGuard works around watching for clients trying to connect to the server and turning those clients into players. Once connected, players can be interacted with in forms of messaging, kicking, banning, or placing in rooms.\n\nCheck out the [player documentation](docs/player.md) for more specific player operations.\n\n### **Rooms**\n\nRooms are used to group players together to perform similar actions together. For example, you can group players together in a room and easily send messages to all of them.\n\nCheck out the [room documentation](docs/room.md) for more specific room operations.\n\n## **Global**\n\nThere are a few actions in GameGuard that are global and affect all players connected to the GameGuard server regardless of the rooms they are in.\n\nCheck out the [global documentation](docs/global.md) for more specific global operations.\n\n## **Tests**\n\nTo run the tests for GameGuard server, you can use:\n\n```bash\n$ npm run test\n```\n\n## **License**\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertcorponoi%2Fgameguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertcorponoi%2Fgameguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertcorponoi%2Fgameguard/lists"}