Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/gestor-backend/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through getting a local Gestor Deportivo server running from scratch and making your first authenticated API call. The entire flow — from cloning the repo to listing teams — takes less than five minutes once your MongoDB instance is ready.
Every endpoint in Gestor Deportivo uses the POST HTTP method, regardless of whether it reads or writes data. Keep this in mind when crafting requests or setting up API clients.

Prerequisites

Before you begin, make sure the following are available on your machine:
  • Node.js 18+nodejs.org
  • npm 9+ — bundled with Node.js
  • MongoDB — a local instance (mongod) or a cloud URI (MongoDB Atlas)
  • Git — to clone the repository

Setup Steps

1

Clone the repository and install dependencies

Clone the project from GitLab and install all Node.js dependencies.
git clone https://gitlab.com/rizofredy5/gestor-backend.git
cd gestor-backend
npm install
This installs Express, Mongoose, JWT, Nodemailer, the Google Cloud Storage client, Socket.io, and all other production and development dependencies declared in package.json.
2

Create your .env file

Create a .env file in the root of the project (one level above src/). This file is read by dotenv at startup.
# .env — place this at the project root, NOT inside /src
PORT=3000
SECRET=your_super_secret_jwt_key

# MongoDB connection string
MONGODB_URL=mongodb://localhost:27017/gestor-deportivo

# Gmail credentials for account verification and password recovery
USER_EMAIL=your-address@gmail.com
PASS_EMAIL=your_gmail_app_password

# Google Cloud Storage
NAMEGOOGLECLOUD=your-gcs-bucket-name
CLIENT_ID=your_google_oauth_client_id
CLIENT_SECRET=your_google_oauth_client_secret
CLIENT_URL=http://localhost:3000
Never commit your .env file to version control. Add it to .gitignore immediately to avoid exposing secrets.
See the Configuration guide for a full description of every variable and how to generate credentials for Gmail and Google Cloud Storage.
3

Start the development server

Launch the API in development mode using nodemon and babel-node for live reloading and ES6+ support.
npm run dev
You should see output similar to:
Server-startup: 312.45ms
Server on port 3000
MongoDB connected
The server is now listening at http://localhost:3000.
4

Register a new user

Create an account by sending a POST request to /api/user/register. The sex field accepts "M" (male) or "F" (female).
curl -X POST http://localhost:3000/api/user/register \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "Alex",
    "lastName": "Ramírez",
    "email": "alex@example.com",
    "password": "StrongPass123!",
    "sex": "M"
  }'
A successful response confirms the user was created and triggers a verification email to the address provided.
{
  "message": "User registered successfully. Please check your email to verify your account."
}
5

Verify your email address

Gestor Deportivo sends a numeric verification code to your email. Submit it to activate the account.
curl -X POST http://localhost:3000/api/user/verify-accounts \
  -H "Content-Type: application/json" \
  -d '{
    "email": "alex@example.com",
    "code": "483921"
  }'
{
  "message": "Account verified successfully."
}
If you did not receive the email, check your spam folder and confirm that USER_EMAIL and PASS_EMAIL are set correctly in .env. See Gmail App Password setup for help generating credentials.
6

Log in and retrieve your token

Authenticate with your verified credentials. The response body contains the JWT you will use on every subsequent request.
curl -X POST http://localhost:3000/api/user/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "alex@example.com",
    "password": "StrongPass123!"
  }'
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3...",
  "user": {
    "_id": "675abc123def456",
    "firstName": "Alex",
    "lastName": "Ramírez",
    "email": "alex@example.com"
  }
}
Store the token value — you will pass it as the access-token header on every protected request.
7

Make your first authenticated request

Use your token to list all teams. Replace <YOUR_TOKEN> with the value returned at login.
Gestor Deportivo uses a custom access-token header — not the standard Authorization: Bearer scheme. Make sure your HTTP client or SDK is configured to send access-token and not Authorization.
curl -X POST http://localhost:3000/api/team/to-list \
  -H "Content-Type: application/json" \
  -H "access-token: <YOUR_TOKEN>" \
  -d '{
    "page": 1,
    "limit": 10
  }'
{
  "teams": [],
  "total": 0,
  "page": 1,
  "pages": 0
}
An empty array is expected on a fresh install. You’re now fully authenticated and ready to create teams, events, and more.

Build for Production

When you’re ready to deploy, compile the ES6+ source with Babel:
npm run build
The transpiled output is written to the build/ directory and can be run with a standard node process — no babel-node required in production.

Available API Routes

All routes accept POST requests and are prefixed with /api/.
RouteDescription
/api/userUser registration, login, verification, profile
/api/teamTeam creation, roster management, listings
/api/playerPlayer profiles, stats, transfers
/api/clubClubHub multi-team groupings
/api/eventTournament/event creation and management
/api/gameMatch scheduling, live data, results
/api/noticeNews and notices scoped to an event
/api/reserveParticipation slot requests
/api/reserve-accepts-teamApprove or reject team reservations

Build docs developers (and LLMs) love