The PokeStock backend is a Node.js application that provides APIs for managing and fetching data related to Pokémon card collections. It integrates with a PostgreSQL database and uses Puppeteer for web scraping to fetch card prices from external sources.
- Fetch Pokémon card prices from external sources (e.g., PriceCharting, eBay).
- Manage user card collections in a PostgreSQL database.
- Provide APIs for fetching and updating card data.
- Cache images and set URLs for efficient data retrieval.
- Node.js (v18 or later)
- PostgreSQL database
- Docker (optional, for running PostgreSQL in a container)
-
Clone the repository:
git clone <repository-url> cd PokeStock
-
Install dependencies:
npm install
-
Set up the PostgreSQL database:
- If using Docker, start the database with:
docker-compose up -d
- Ensure the database credentials match the configuration in
index.js:const pool = new Pool({ user: 'postgres', host: 'localhost', database: 'pokecollection', password: 'postgres', port: 5432, });
- If using Docker, start the database with:
-
Start the server:
npm dev
GET /- Returns a welcome message and basic usage instructions.
GET /cardPrice- Fetches the price of a specific Pokémon card.
- Query Parameters:
pokemonSet: The set name of the card.pokemonName: The name of the card.
GET /images- Returns cached set URLs and images.
GET /give/:SetName- Fetches card details for a specific set.
- Path Parameter:
SetName: The name of the set.
GET /seturls- Populates and returns set URLs.
GET /card/:CardId- Fetches details for a specific card.
- Path Parameter:
CardId: The ID of the card.
POST /updateCollection- Adds or updates card data in the user's collection.
- Request Body:
{ "userId": "user123", "setName": "set-name", "cardName": "card-name", "cardNumber": "card-number", "basePrice": 10.0, "reversePrice": 12.0, "pokeBallPrice": 15.0, "masterBallPrice": 20.0, "baseQuantity": 1, "reverseQuantity": 2, "pokeBallQuantity": 3, "masterBallQuantity": 4 }
GET /getCollection/:userId- Fetches the card collection for a specific user.
- Path Parameter:
userId: The ID of the user.
GET /getCard- Fetches details for a specific card in a set.
- Query Parameters:
setName: The name of the set.cardId: The ID of the card.
EXPO_PUBLIC_API_BASE_URL: Base URL for the API (used in the frontend).
This project is licensed under the MIT License.