Skip to content

M336G/senddb_cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SendDB Cache

A caching proxy for SendDB focusing on efficiently checking if levels have been sent or not

Prerequisites

  • Rust installed
  • A device or server capable of running 24/7

Running

1. Download the repository manually or clone it:

git clone https://github.com/M336G/senddb_cache.git
cd senddb_cache

2. Create a .env file and fill it according to your needs using .env.example as a template:

  • Enter a custom port if you need to change the default one (8273)
  • Specify SendDB's endpoint URL for accessing a level's data
  • Set an expiration for how many minutes before temporarily cached not sent levels are able to be re-checked
  • Set for how long sent levels will be cached by Cloudflare
  • Set for how long not sent levels will be cached by Cloudflare

3. Start the instance with:

  • cargo run --release for production
  • cargo run for development/testing

Once you've done all of this, you should have a running instance!

Usage

Once you've got your instance running, you may use these endpoints:

Method Endpoint Description
GET / Check if the server's up or
GET /stats Get some statistics about the server
GET /level/<id> Check if a level has been sent or not
GET /ws Initializes a new WebSocket connection
GET /swagger Get documentation about each endpoint
GET /swagger/openapi.json Get JSON documentation about each endpoint

Responses to GET /level/<id> will look like this:

{
    "error": null,
    "sent": true
}
  • error will be null on success or a string describing the error
  • sent will be true if the level has been sent, false if not, or null if an error occurred

Additionally, if you are looking for something more efficient, you may use the WebSocket endpoint:

Once connected to GET /ws, you may send any of the following:

  • { "type": "status" }: allows you to check if the connection's still up or not (it will just return { "error": null })
  • { "type": "stats" }: returns statistics about the server (same response as GET /stats)
  • { "type": "level", "ids": [id1, id2, ...] }: checks if one or multiple levels have been sent (up to 50 at a time)

Responses to { "type": "level", ... } will look like this:

{
    "error": null,
    "levels": {
        "6508283": { "error": null, "sent": false },
        "128279390": { "error": null, "sent": true }
    }
}

Each level entry has the same kind of response as GET /level/<id>

License

This project is licensed under the MIT License.

About

A caching proxy for SendDB focusing on efficiently checking if levels have been sent or not

Resources

License

Stars

Watchers

Forks

Contributors

Languages