Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/deveshsangwan/cricketscoreapi
- Owner: deveshsangwan
- License: other
- Created: 2023-02-25T16:17:40.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-14T18:01:01.000Z (9 months ago)
- Last Synced: 2024-11-14T23:38:57.786Z (2 months ago)
- Topics: 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
- Language: TypeScript
- Homepage: https://deveshsangwan.github.io/cricketScoreApi/
- Size: 209 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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.