Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deveshsangwan/cricketscoreapi

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.
https://github.com/deveshsangwan/cricketscoreapi

api api-rest chai cheerio cricket cricket-score docker express jwt-authentication livescore mocha mocha-chai mongodb nodejs prisma realtime-data rest-api sports-data typescript webscraping

Last synced: 7 days ago
JSON representation

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.

Awesome Lists containing this project

README

        

# ๐Ÿ Cricket Score API

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.

## ๐Ÿ“š Table of Contents

- [Cricket Score API](#cricket-score-api)
- [Status](#status)
- [Code Coverage](#code-coverage)
- [Getting Started](#getting-started)
- [Usage](#usage)
- [Running Tests](#running-tests)
- [License](#license)

## ๐Ÿš€ Status

[![Run Tests](https://github.com/deveshsangwan/cricketScoreApi/actions/workflows/test.yml/badge.svg)](https://github.com/deveshsangwan/cricketScoreApi/actions/workflows/test.yml)

## ๐Ÿ“Š Code Coverage

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

[![codecov](https://codecov.io/gh/deveshsangwan/cricketScoreApi/graph/badge.svg?token=A3JMLLNTG4)](https://codecov.io/gh/deveshsangwan/cricketScoreApi)
![Functions](https://img.shields.io/badge/functions-92.85%25-brightgreen.svg?style=flat)
![Lines](https://img.shields.io/badge/lines-84.65%25-yellow.svg?style=flat)

## ๐Ÿš€ 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 pnpm if you haven't already: `npm install -g pnpm`
3. Install dependencies: `pnpm install`
4. Create a `.env` file in the root directory of the project. Add the MongoDB URL like so: `DATABASE_URL=`. Replace `` with your actual MongoDB URL.
5. Generate Prisma client: `pnpm prisma generate`
6. Start the server: `pnpm 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= cricket-score-api`

Remember to replace `` with your actual MongoDB URL.

## ๐Ÿ› ๏ธ Technologies Used

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

## ๐Ÿ“ 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:

```json
{
"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: `pnpm test`

This command will run the test suite for the project.

2. 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.

## ๐Ÿ“œ License

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