This project is a RESTful API for managing video game data, providing comprehensive CRUD operations and specialized endpoints for retrieving specific game information.
The Video Games API provides the following features:
- CRUD Operations: Create, read, update, and delete video game entries
- Advanced Filtering: Filter games by platform, genre, rating, and price
- Search Functionality: Search games by title, developer, and other attributes
- Specialized Endpoints: Access specific game properties like screenshots, system requirements, and DLC content
- Backend: Node.js with Express.js
- Database: MongoDB with Mongoose ODM
- Testing: Jest with Supertest
- Additional Libraries:
- cors: For Cross-Origin Resource Sharing
- dotenv: For environment variable management
- mongodb-memory-server: For in-memory MongoDB testing
- sinon: For mocking and stubbing
├── models/ # Database models
│ └── Game.js # Game schema definition
├── routes/ # API routes
│ └── gameRoutes.js # Game-related endpoints
├── tests/ # Test files
│ ├── api/ # API-specific tests
│ ├── integration/ # Integration tests
│ ├── models/ # Model tests
│ └── routes/ # Route tests
├── server.js # Express server setup
├── seedData.js # Database seeding script
└── README.md # This file
- Node.js (v14 or higher)
- MongoDB (local or Atlas)
-
Clone the repository:
git clone https://github.com/Kanishk1420/Game-library-service.git cd video-games-api
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory with the following variables:MONGO_URI=mongodb+srv://your-connection-string PORT=5000
-
Seed the database (If you want to populate the database with initial game data):
node seedData.js
-
Start the server:
npm start
The API will be available at http://localhost:5000
.
This project uses Jest as its testing framework and includes various test types:
- Unit tests
- Integration tests
- API tests
- Mock tests
npm test
npm test -- tests/api/security.test.js
npm test -- --coverage
This project also uses Keploy for automated API test generation and validation. View the test results here:
Keploy automatically generates test cases based on API traffic and ensures compatibility with the API specification.
To view the test coverage report:
-
Run the tests with coverage:
npm test -- --coverage
-
The coverage report will be displayed in the terminal, showing:
- Statement coverage
- Branch coverage
- Function coverage
- Line coverage
-
For a detailed HTML report, check the
coverage/lcov-report/index.html
file:open coverage/lcov-report/index.html # macOS start coverage/lcov-report/index.html # Windows
Note: To take a screenshot of your coverage report, run the tests with coverage, then open the HTML report in your browser and take a screenshot. Save it in the project root as
coverage-screenshot.png
.
GET /api/games
- Get all games with paginationGET /api/games/:id
- Get a specific game by IDPOST /api/games
- Create a new gamePUT /api/games/:id
- Update a gamePATCH /api/games/:id
- Partially update a gameDELETE /api/games/:id
- Delete a game
GET /api/games/search
- Search games by title, developer, etc.GET /api/games?platform=PC
- Filter games by platformGET /api/games?genre=RPG
- Filter games by genreGET /api/games?minRating=8
- Filter games by minimum ratingGET /api/games?maxPrice=60
- Filter games by maximum price
GET /api/games/:id/screenshots
- Get game screenshotsGET /api/games/:id/requirements
- Get game system requirementsGET /api/games/:id/dlc
- Get game DLC informationGET /api/games/:id/coverImage
- Get game cover imageGET /api/games/with-dlc
- Get all games with DLCGET /api/games/:id/:property
- Get a specific property of a game
The test suite aims for comprehensive coverage of all API endpoints and functionality:
- Integration Tests: Test full API functionality with real database connections
- Security Tests: Verify API handles malicious inputs and edge cases
- Performance Tests: Ensure API response times meet requirements
- Mock Tests: Verify route handlers with mocked database interactions
- Model Tests: Validate schema and model validation functionality
Interactive API documentation is available at /api-docs
when the server is running.
We welcome and encourage contributions to this project! Here's how you can help:
- Adding Games: Feel free to create pull requests to update the
seedData.js
file with new game entries - Updating Game Information: If you notice outdated or incorrect game information, PRs to correct the data are appreciated
- Data Format: Ensure new game entries follow the existing schema format
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- This API is free to use for personal, educational, and commercial projects
- Please include attribution to this repository when using the API in your projects
- Consider contributing back any improvements or bug fixes you develop
All contributions are subject to the MIT License as detailed below.
This project is licensed under the MIT License - see below for details:
MIT License
Copyright (c) 2025 [Kanishk]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.