This API provides endpoints to manage movie ratings, comments, and watchlists. It allows users to rate movies, leave comments, and add movies to their watchlists.
- Clone the repository:
git clone <repository_url>
- Install dependencies:
npm install
- Node.js
- PostgreSQL or any other supported database (configured in the Prisma schema).
- There should be a
.env
file in the project root folder, withDATABASE_URL
andJWT_SECRET
defined. I used render to set up a free PostgreSQL db.
- Update the
.env
file with your database connection details and other environment variables. -
DATABASE_URL="postgres://xxxxxxxxx" JWT_SECRET = "2RXuR@xxxxxxxx"
- Run database migrations:
npx prisma migrate dev
Start the server: npm run dev
The server will be running on http://localhost:3000
.
POST /signin
: Sign in to the application.POST /user
: Create a new user.PUT /user
: Update user information.GET /user
: Get user details.
POST /movie/:id
: Add a new movie.GET /movie/:id
: Get movie details.
GET /comment/:movieId
: Get comments for a movie.POST /comment
: Create a new comment.PUT /comment/:movieId
: Update a comment.DELETE /comment/:id
: Delete a comment.
GET /rating/:movieId
: Get ratings for a movie (Returns the average rating for a movie across all users).PUT /rating
: Update a rating.POST /rating/:movieId
: Create a new rating (Modifies an existing rating if the user resubmits the rating).
GET /watchlist
: Get the user's watchlist.DELETE /watchlist/:movieId
: Remove a movie from the watchlist.POST /watchlist/:movieId
: Add a movie to the watchlist.
If any error occurs during the API request handling, a 500 status code will be returned along with an error message in the response body.
Contributions are welcome! If you find any issues or want to enhance the API, feel free to open a pull request.
This project is licensed under the MIT License.
- Prisma: Used as the database ORM.
- Express: Used as the web framework.
- bcrypt: Used for password hashing.
- jsonwebtoken: Used for authentication and authorization.
- dotenv: Used for environment variable management.
Feel free to modify the readme file to suit your specific requirements and add any additional information or instructions that might be relevant to your project.