Skip to content

Welcome to the Cricket Score API! This project is designed to provide real-time cricket scores using TypeScript and npm. It uses technologies like Cheerio for web scraping, Prisma for accessing MongoDB, Express-jwt for authentication, and Chai and Mocha for testing.

License

Notifications You must be signed in to change notification settings

deveshsangwan/cricketScoreApi

Repository files navigation

🏏 Cricket Score API

Welcome to the Cricket Score API! This project is designed to provide real-time cricket scores using TypeScript and npm. It uses technologies like Cheerio for web scraping, Prisma for accessing MongoDB, Express-jwt for authentication, and Chai and Mocha for testing. The project is also Dockerized for easy setup and deployment.

📚 Table of Contents

🚀 Status

Run Tests

📊 Code Coverage

Our aim is to maintain high code coverage to ensure the quality of the project. Here are our current stats:

codecov Functions Lines

🚀 Getting Started

To get a copy of the project up and running on your local machine, follow these steps:

  1. Clone the repository: git clone https://github.com/deveshsangwan/cricketScoreApi.git
  2. Install dependencies: npm install
  3. Create a .env file in the root directory of the project. Add the MongoDB URL like so: DATABASE_URL=<your-mongodb-url>. Replace <your-mongodb-url> with your actual MongoDB URL.
  4. Generate Prisma client: npx prisma generate
  5. Start the server: npm run dev

You can also run the project with Docker:

  1. Build the Docker image: docker build -t cricket-score-api .
  2. Run the Docker container, passing the MongoDB URL as an environment variable: docker run -p 3000:3000 -d -e DATABASE_URL=<your-mongodb-url> cricket-score-api

Remember to replace <your-mongodb-url> with your actual MongoDB URL.

🛠️ Technologies Used

This project uses a number of technologies and tools:

  • Cheerio: Used for web scraping to fetch live cricket match data.
  • Prisma: Used as an ORM for accessing MongoDB to improve performance.
  • Express-jwt: Used for authentication. A valid token is required to hit all the endpoints other than /generateToken.
  • Chai and Mocha: These libraries are used for writing and running tests to ensure the quality of the project.
  • Docker: Used for creating a containerized version of the application, ensuring that it runs the same way in every environment.

📝 Usage

  • Make a GET request to /liveMatches to get the URLs of all the current live matches.
  • Make a GET request to /matchStats to get the statistics for all matches.
  • Make a GET request to /matchStats/:matchId to get the statistics for a single match. Replace :matchId with the ID of the match you want statistics for.
  • Make a POST request to /generateToken with a JSON body containing clientId and clientSecret to generate a token. The JSON body should look like this:
{
    "clientId": "yourClientId",
    "clientSecret": "yourClientSecret"
}

Note: A valid token is required for hitting all the endpoints other than /generateToken. Include the token in the Authorization header of your requests.

🧪 Running Tests

After setting up the project, you can run the tests to ensure everything is working as expected. Follow these steps:

  1. Run the test command: npm run test

This command will run the test suite for the project.

  1. If you want to check the code coverage of your tests, you can run: npm run test:coverage

This command will run the tests and generate a coverage report.

📜 License

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) License. See the LICENSE.md file for details.

About

Welcome to the Cricket Score API! This project is designed to provide real-time cricket scores using TypeScript and npm. It uses technologies like Cheerio for web scraping, Prisma for accessing MongoDB, Express-jwt for authentication, and Chai and Mocha for testing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published