Skip to content

Commit

Permalink
Merge pull request #13 from deveshsangwan/migrate-to-prisma
Browse files Browse the repository at this point in the history
updated readme and dockerfile for prisma
  • Loading branch information
deveshsangwan authored Apr 14, 2024
2 parents 9b25982 + 4eb22d7 commit c935dd9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ RUN apk add --no-cache bash
RUN npm cache clean --force
RUN npm install

# Copy Prisma schema
COPY prisma ./prisma

# Generate Prisma client
RUN npx prisma generate

# Copy the rest of the application code
COPY ./ .

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🏏 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, MongoDB for caching, Express-jwt for authentication, and Chai and Mocha for testing. The project is also Dockerized for easy setup and deployment.
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

Expand Down Expand Up @@ -30,13 +30,14 @@ To get a copy of the project up and running on your local machine, follow these

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: `MONGO_URL=<your-mongodb-url>`. Replace `<your-mongodb-url>` with your actual MongoDB URL.
4. Start the server: `npm run dev`
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 MONGO_URL=<your-mongodb-url> 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.

Expand All @@ -45,7 +46,7 @@ Remember to replace `<your-mongodb-url>` with your actual MongoDB URL.
This project uses a number of technologies and tools:

- **Cheerio**: Used for web scraping to fetch live cricket match data.
- **MongoDB**: Used as a database for caching match data to improve performance.
- **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.
Expand Down
10 changes: 5 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ type MatchstatsTeam1PreviousInnings {
}

type MatchstatsTeam2 {
isBatting Boolean
name String
isBatting Boolean?
name String?
overs String?
/// Could not determine type: the field only had null or empty values in the sample set.
previousInnings Json?
score String
wickets String
score String?
wickets String?
}

model livematches {
Expand All @@ -68,4 +68,4 @@ model matchstats {
isLive Boolean
@@index([createdAt], map: "createdAt_1")
}
}

0 comments on commit c935dd9

Please sign in to comment.