From e9f37775e387a01229fad0c8472d8fbecb21b5eb Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 22 Dec 2024 22:40:15 -0700 Subject: [PATCH] Add some docs --- .env.example | 13 ++++++++ README.md | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ TODO.md | 3 ++ 3 files changed, 104 insertions(+) create mode 100644 .env.example create mode 100644 README.md create mode 100644 TODO.md diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..373e493 --- /dev/null +++ b/.env.example @@ -0,0 +1,13 @@ +DISCORD_TOKEN=DISCORD_BOT_TOKEN_HERE # Your discord bot token +ADMIN_GUILD=DISCORD_ADMIN_GUILD_ID # The guild ID of the guild you want to be the admin guild +REGISTER_COMMANDS=true/false # If you want to register commands on startup +RESET_ADMIN=true # If true, will delete all admin users and create user 'admin' with either a generated password or the password in DEV_PWD +DEV_PWD=admin # The password for the admin user if RESET_ADMIN is true, if unset will be a random password +DB_HOST=127.0.0.1 # MariaDB Host +DB_USER=ubs # MariaDB User +DB_PASS=ubs # MariaDB Password +DB_DATABASE=ubs # MariaDB Database +LOGFILE=access.log # Log file for API request logging +TRUST_PROXY=true # Whether to trust X-Forwarded-For as the IP address. +PROXY_IP=10.10.0.1 # IP of your reverse proxy (IPv4 only, will be converted from v6) +ROBLOSECURITY=ROBLOSECURITY_COOKIE # Your ROBLOSECURITY cookie. Not used as of now, but will be used for future features. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb4b121 --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# RTECH Unified Ban System + +## Features +- [X] MariaDB database for storing ban data +- [X] REST API for querying bans +- [ ] Web interface for querying bans +- [X] Admin web interface for managing bans +- [X] Mass import of bans +- [ ] Mass export of bans +- [ ] Ban appeal system +- [ ] Ban appeal system admin interface +- [ ] Discord integrations (Notifications, Appeals, Querying) + +## Installation +1. Clone the repository +2. Run `npm install` +3. Configure the `.env` file with your database and API settings (see `.env.example`) +4. Run `node .` to start the server + +## API Documentation +### 🔓 Unauthenticated Endpoints +`GET /health` - Healthcheck endpoint (For Uptime Kuma) + +`GET /v1/myIP` - Get your IP address (As seen by the server. Useful for debugging) + +`GET /v1/info` - Get information about the API (Version, All reason flags) + +`GET /api/v1/bans` - Get all bans + +`GET /api/v1/ban/roblox/:robloxId` - Get bans by Roblox ID + +`GET /api/v1/ban/discord/:discordId` - Get bans by Discord ID + +### 🔒 Authenticated Endpoints +`GET /admin` - Renders the admin dashboard. + +`GET /admin/edit/:id` - Renders the edit ban page for a specific ban. + +`GET /admin/create` - Renders the create ban page. + +`POST /admin/create` - Creates a new ban. +**Post Data:** +```json +{ + "robloxId": "string", + "discordId": "string", + "reason": "string", + "duration": "number" +} +``` + +`POST /admin/edit/:id` - Edits an existing ban. +**Post Data:** +```json +{ + "reason": "string", + "duration": "number" +} +``` + +`GET /admin/import` - Renders the import page for uploading ban data. + +`POST /admin/import` - Handles the import of ban data from a file. +**Post Data:** +- `fileInput`: File upload (CSV format) +- `fileType`: Type of the file being uploaded (e.g., 'csv', 'mfd') + +`GET /admin/uploadStatus` - Renders the upload status page. + +`GET /admin/api/bans` - Retrieves all bans. + +`GET /admin/api/uploads/:id` - Retrieves the status of a specific upload. + +`GET /admin/api/uploads` - Retrieves the status of all uploads. + +`GET /admin/login` - Renders the admin login page. + +`POST /admin/login` - Handles admin login. +**Post Data:** +```json +{ + "username": "string", + "password": "string", + "totp": "string" +} +``` + +`ALL /admin/logout` - Logs out the admin. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..36d5218 --- /dev/null +++ b/TODO.md @@ -0,0 +1,3 @@ +# TODO List +- [ ] Add public ban query page based on either Roblox ID, Discord ID, or Ban ID +- [ ] Implement appeal system for banned users (Do we allow anybody to appeal with just a ban ID? Or do we use oauth?) \ No newline at end of file