Git Product home page Git Product logo

riot-api-proxy-server's Introduction

Riot API Proxy Server

A Cloudflare Worker that acts as a proxy server for the Riot Games API, managing rate limits and caching for better performance.

Features

  • Rate limiting for both clients and the server itself
  • Caching successful API responses
  • Extracting and setting the region for API requests
  • Automatic handling of Riot API rate limits

Installation

  1. Ensure you have Node.js, npm, and the Cloudflare Wrangler CLI installed on your system.

  2. Clone the repository and navigate to the project folder:

    git clone https://github.com/st4s1k/riot-api-proxy-server.git
    cd riot-api-proxy-server
  3. Install the dependencies:

    npm install
  4. Configure the wrangler.toml file with your Cloudflare account ID and the appropriate API key.

  5. Add your Riot Games API key as an environment variable in your Cloudflare Worker:

    wrangler secret put API_KEY

Usage

  1. Install dependencies:

    npm install
  2. Build the project:

    npm run build

    This command will compile TypeScript files and output the result to the dist directory.

  3. Run the project in development mode:

    npm run start

    This command will start the development server with live reloading, which will automatically recompile and restart the application when changes are detected.

  4. Deploy the project:

    npm run deploy

    This command will deploy your application to Cloudflare Workers.

  5. View real-time logs:

    npm run tail

    This command will display real-time logs from your Cloudflare Worker application.

  6. Run tests:

    npm test

    This command will run the tests using Jest.

  7. Run tests silently:

    npm run test:silent

    This command will run the tests using Jest without console output.

  8. Run tests with logs output to a file in ./logs/ directory:

    npm run test:log

    This command will run the tests and save the output to a log file located in the logs directory. The log file will be named with the format: YYYY-MM-DD_HH-mm-ss.log

Configuration

The worker configuration can be modified through environment variables or [vars] section in the wrangler.toml file:

  • DEFAULT_REGION: Default region for Riot API requests (default: "euw1")
  • CACHE_DURATION: Cache duration in seconds (0 to disable) (default: 60 seconds)
  • CLIENT_RATE_LIMIT_MULTIPLIER: The multiplier is used to reduce the rate limit to avoid hitting the server rate limit (default: 0.5)

Secret Environment Variables

Create a .env file in the project root directory and add the environment variables there. The .env file is ignored by git and will not be committed to the repository. It should contain the Riot Games API key:

  • API_KEY: Riot Games API key

    API_KEY=RGAPI-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

License

This project is released under the MIT License. See the LICENSE file for details.

riot-api-proxy-server's People

Contributors

st4s1k avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.