Skip to main content

Prerequisites

Before you begin, ensure you have the following installed on your system:

Node.js

Version 14.x or higher recommended

npm

Comes bundled with Node.js
To check your current Node.js version, run node --version in your terminal.

Installation Steps

1

Clone the Repository

First, clone the LoL Tracker Backend repository to your local machine:
git clone https://github.com/ValentinSetti/tracker-lol-backend.git
cd tracker-lol-backend
2

Install Dependencies

Install all required npm packages using the package manager:
npm install
This will install the following dependencies:
  • express (v5.2.1) - Web framework for Node.js
  • axios (v1.13.5) - HTTP client for making API requests
  • cors (v2.8.6) - Middleware for enabling CORS
  • dotenv (v17.3.1) - Environment variable management
All dependencies are listed in package.json and will be installed automatically.
3

Configure Environment Variables

Create a .env file in the root directory of the project:
touch .env
Add your Riot Games API key to the .env file:
.env
RIOT_API_KEY=your_riot_api_key_here
Never commit your .env file to version control. It’s already included in .gitignore to prevent accidental exposure of your API key.
To obtain a Riot Games API key, visit Riot Developer Portal and sign in with your Riot account.
4

Start the Server

Launch the development server:
node index.js
You should see the following output:
Servidor corriendo en http://localhost:3000
5

Verify Installation

Test that the server is running correctly by visiting the root endpoint:
curl http://localhost:3000
Expected response:
¡El servidor del LoL Tracker está vivo, Guillote!
You can also open http://localhost:3000 in your web browser to see this message.

Server Configuration

The server is configured in index.js with the following settings:
index.js
const express = require('express');
const cors = require('cors');
const axios = require('axios'); 
require('dotenv').config();

const app = express();
const PORT = 3000;

app.use(cors());
app.use(express.json());

What Each Line Does:

  • Line 1-3: Import required dependencies (Express, CORS, Axios)
  • Line 4: Load environment variables from .env file using dotenv
  • Line 6: Initialize Express application
  • Line 7: Set the server port to 3000
  • Line 9: Enable CORS to allow cross-origin requests from frontend applications
  • Line 10: Enable JSON body parsing for incoming requests

Common Setup Issues

If you see an error that port 3000 is already in use:Solution 1: Change the port in index.js:
const PORT = 3001; // or any available port
Solution 2: Kill the process using port 3000:
# On Linux/Mac
lsof -ti:3000 | xargs kill -9

# On Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F
If you encounter module import errors:
  1. Delete node_modules and reinstall:
rm -rf node_modules
npm install
  1. Clear npm cache:
npm cache clean --force
npm install
If you see API key related errors:
  1. Ensure .env file exists in the root directory
  2. Verify the .env file contains: RIOT_API_KEY=your_key_here
  3. Restart the server after creating/modifying .env
  4. Check that require('dotenv').config() is called at the top of index.js
If you’re getting CORS errors when connecting from a frontend:The server already has CORS enabled by default:
app.use(cors());
This allows requests from any origin. For production, you should restrict origins:
app.use(cors({
  origin: 'https://your-frontend-domain.com'
}));

Next Steps

Configuration

Learn about environment variables and server configuration

Authentication

Set up Riot API authentication and understand rate limits

API Endpoints

Explore available API endpoints

Quick Start

Make your first API request

Build docs developers (and LLMs) love