Skip to content

AmnesiaRP/global_bans

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API for GlobalBans project

Installation

Recommended

  • node.js version 20
  • npm version 9

Install dependencies

npm install

Environment file

Create a file named .env in the root directory of the project. The file should contain the following variables:

APP_PORT=8080

DB_HOST=
DB_PORT=3306
DB_NAME=
DB_USER=
DB_PASS=

You have to fill in the values for the database connection. The database must be created beforehand.

Initialize database

You can initialize the database by running the SQL script ./sql/install.sql.

Start the server

npm start

API

Authentication

The API uses the Authorization header to authenticate requests. The value of the header should be the API token of the server.

Get a user's bans

Returns the user's bans with the given Steam ID.

GET /users/STEAM_0:x:xxxxxxxx HTTP/1.1
Authorization: <API token>
{
  "steam_id": "STEAM_0:x:xxxxxxxx",
  "bans": [
    {
      "server": "Server 1",
      "reason": "Cheating is bad"
    },
    {
      "server": "Server 2",
      "reason": "Troll"
    }
  ]
}

Add ban to a user

Adds a ban to the user with the given Steam ID.

POST /users/STEAM_0:x:xxxxxxxx/bans HTTP/1.1
Authorization: <API token>

{
  "reason": "Cheating is bad"
}
{
  "steam_id": "STEAM_0:1:78946513",
  "server": "Server 1",
  "reason": "Cheating is bad"
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published