This is a RESTful API for a movie application that allows users to manage movies and their favorites. The API provides authentication using Passport and JWT, email verification, and password reset functionality. It can be run both locally and in a Docker container.
- User authentication with email
- Email verification
- Password reset
- Movie management (create, retrieve, update, delete)
- Favorite movies management (add, remove)
Make sure you have the following installed:
- Node.js
- npm (Node Package Manager)
- MySQL (or any other supported database)
- Docker (optional)
To get the API up and running, follow these steps:
- Clone the repository:
git clone https://github.com/gsshaun/movie-app-api.git
- Install the dependencies:
cd movie-app-api
npm install
- Set up the environment variables:
Create a .env
file in the root directory of the project and provide the necessary configuration values. Here's an example:
DOMAIN=YOUR_DOMAIN
ETHEREAL_USER=YOUR_ETHEREAL_ID
ETHEREAL_PASS=YOUR_ETHEREAL_PASSWORD
JWT_SECRET=YOUR_ETHEREAL_SECRET
DB_HOST=host.docker.internal
DB_PORT=3306
DB_USER=root
DB_PASSWORD=YOUR_DB_PASSWORD
DB_NAME=movieapi
- Set up the database:
Create a database in your MySQL server with the name specified in the .env
file. Make sure the database credentials (host, port, username, password) are correctly set in the .env
file.
- Start the API:
npm run start:dev
The API will be accessible at http://localhost:3000
.
If you prefer running the API in a Docker container, follow these additional steps:
- Build the Docker image:
docker build -t movieapi .
- Run the Docker container:
docker run -d -p 3000:3000 --name movieapi-container movieapi
The API will be accessible at http://localhost:3000
The API provides the following endpoints:
POST /users/signup
- Create a new user accountPOST /users/signin
- Sign in to an existing user accountGET /users/verify?token={verificationToken}
- Verify user's emailPOST /users/forget-password
- Send password reset emailPOST /users/reset-password
- Reset user's password
POST /movies
- Create a new movieGET /movies
- Retrieve all moviesGET /movies/:id
- Retrieve a specific movie by IDPATCH /movies/:id
- Update a movieDELETE /movies/:id
- Delete a movie
POST /favorites/:movieId
- Add a movie to favoritesDELETE /favorites/:movieId
- Remove a movie from favorites
Authentication is required to access certain endpoints. When signing up or signing in, the API will return a JWT (JSON Web Token) that should be included in the Authorization
header of subsequent requests as a Bearer token. Example:
Authorization: Bearer <jwt_token>
You can run the tests for the API using the following command:
npm run test
Contributions are welcome! If
you find any issues or have suggestions for improvements, please create a new issue or submit a pull request.
This project is licensed under the UNLICENSED license.