Welcome to the Cricket Score API! This project is designed to provide real-time cricket scores using TypeScript and pnpm. 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.
Our aim is to maintain high code coverage to ensure the quality of the project. Here are our current stats:
To get a copy of the project up and running on your local machine, follow these steps:
- Clone the repository:
git clone https://github.com/deveshsangwan/cricketScoreApi.git
- Install pnpm if you haven't already:
npm install -g pnpm
- Install dependencies:
pnpm install
- 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. - Generate Prisma client:
pnpm prisma generate
- Start the server:
pnpm dev
You can also run the project with Docker:
- Build the Docker image:
docker build -t cricket-score-api .
- 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.
This project uses a number of technologies and tools:
- pnpm: Used as the package manager for better dependency management and disk space efficiency
- 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
- 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 containingclientId
andclientSecret
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.
After setting up the project, you can run the tests to ensure everything is working as expected. Follow these steps:
- Run the test command:
pnpm test
This command will run the test suite for the project.
- If you want to check the code coverage of your tests, you can run:
pnpm test:coverage
This command will run the tests and generate a coverage report.
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.