Backend API for PokéManager application - Manage your custom Pokémon collection with battle system and XP tracking.
- Express - Web framework for Node.js
- TypeScript - Type-safe JavaScript
- File System - JSON file-based database
- Axios - HTTP client for PokeAPI
- CORS - Cross-Origin Resource Sharing
- Morgan - HTTP request logger
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/pokemon |
Create a new Pokémon |
| GET | /api/pokemon |
Get all Pokémon |
| GET | /api/pokemon/:id |
Get Pokémon by ID |
| PUT | /api/pokemon/:id |
Update Pokémon |
| DELETE | /api/pokemon/:id |
Delete Pokémon |
| PUT | /api/pokemon/:id/add-xp |
Add XP to Pokémon |
| POST | /api/pokemon/:id/level-up |
Level up Pokémon |
| POST | /api/pokemon/:id/nickname |
Update nickname |
| GET | /api/pokemon/search |
Search Pokémon |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/battle/random/:pokemonId |
Battle vs random Pokémon |
| POST | /api/battle/train |
Battle between your Pokémon |
| POST | /api/battle/sparring/:pokemonId |
Training battle |
| GET | /api/battle/random-opponent |
Get random opponent |
| GET | /api/battle/available-opponents |
Get multiple opponents |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/battle/history |
Get all battle history |
| GET | /api/battle/history/:pokemonId |
Get Pokémon battle history |
| GET | /api/battle/stats/:pokemonId |
Get battle stats |
| DELETE | /api/battle/history |
Clear battle history |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/stats/strongest |
Top strongest Pokémon |
| GET | /api/stats/most-experienced |
Most experienced Pokémon |
| GET | /api/stats/battle-winners |
Best win ratio |
| GET | /api/stats/type-distribution |
Type distribution |
| GET | /api/stats/collection |
Collection stats |
# Clone the repository git clone https://github.com/yourusername/pokemanager-server.git cd pokemanager-server # Install dependencies npm install # Create environment file cp .env.example .env # Start development server npm run dev # Build for production npm run build # Start production server npm start
pokemanager-server/
├── src/
│ ├── controllers/ # Business logic
│ ├── routes/ # API routes
│ ├── middleware/ # Express middleware
│ ├── services/ # Data services
│ ├── utils/ # Helper functions
│ ├── types/ # TypeScript types
│ ├── data/ # JSON database
│ ├── app.ts # Express app
│ └── server.ts # Server entry point
├── .env # Environment variables
├── package.json
└── tsconfig.json
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 5000 |
NODE_ENV |
Environment | development |
CLIENT_URL |
Frontend URL | http://localhost:5173 |
POKEAPI_URL |
PokeAPI URL | https://pokeapi.co/api/v2 |
The API uses JSON files for data persistence:
src/data/pokemon.json- Stores Pokémon and battle history
Import the Postman collection to test all endpoints:
PokéManager API Postman Collection
MIT License - feel free to use this project for learning!
- PokeAPI for providing Pokémon data
- Express for the amazing framework
- TypeScript for type safety