Backend for MFLIX
-
Clone the repository:
git clone https://github.com/2024-Open-Soft/Backend.git
-
Navigate to the project directory:
cd Backend
-
Install dependencies:
npm install
or alternatively
npm i
Make sure to have nodejs and npm installed
-
Create an account at https://razorpay.com/.
-
Go to the dashboard after logging in: https://dashboard.razorpay.com/app/dashboard
-
Create an API key from
Accounts and Settings
: https://dashboard.razorpay.com/app/website-app-settings/api-keysRemember to save the
key id
andkey secret
-
Add the
key id
andkey secret
as environment variables. -
Create an webhook (for payment verification) from
Accounts and Settings
with the following configurations at https://dashboard.razorpay.com/app/website-app-settings/webhooksVariables Values Webhook URL <your backend url>/payment/verification
Webhook Secret Generate a strong secret and save it Active events Select payment.captured
DATABASE_URL="<mongodb url>"
RZ_KEY_ID="<razorpay key id>"
RZ_KEY_SECRET="<razorpay key secret>"
RZ_WEBHOOK_SECRET="<razorpay webhook secret>"
TWILIO_ACCOUNT_SID="<twilio account sid>"
TWILIO_AUTH_TOKEN="<twilio auth token>"
TWILIO_PHONE_NUMBER="<twilio phone number>"
TWILIO_MS_SID="<twilio ms sid>"
AWS_ACCESS_KEY_ID="<aws access key id>"
AWS_SECRET_ACCESS_KEY="<aws secret access key>"
AWS_MEDIACONVERT_ROLE="<aws media convert role>"
AWS_S3_BUCKET="<aws s3 bucket>"
AWS_CLOUDFRONT_KEYPAIR_ID="<aws cloudfront key pair id>"
AWS_CLOUDFRONT_DOMAIN="<aws cloudfront domain>"
HUGGINGFACE_API_KEY_1="<huggingface api key 1>"
HUGGINGFACE_API_KEY_2="<huggingface api key 2>"
OPENAI_API_KEY_1="<openai api key 1>"
OPENAI_API_KEY_2="<openai api key 2>"
OPENAI_API_URL="<openai api url>"
PORT="<port for backend>"
BASE_URL="<base url for frontend>"
EMAIL="<email to send otp with>"
EMAIL_PASSWORD="<app password for email>"
Use the following command to run:
npm run dev
Route | Sub route | Method | Description |
---|---|---|---|
/admin | /user | get | get all users |
/user/:id | get | get a particular user by id | |
/user | post | create user | |
/user/:id | put | update user by id | |
/user/:id | delete | delete a user by id | |
/movie/:id | get | get a movie by id | |
/movie | get | get all movies | |
/movie/comments | delete | delete a comment | |
/plan | post | create a subscription plan | |
/plan/:id | put | update plan by id | |
/plan/:id | delete | delete plan by id | |
/movie/upload | post | create a new movie and upload movie details | |
/movie/:movieId/upload | post | upload movie file by movieId | |
/movie/:id | patch | update movie by id | |
/movie/:movieId/delete | delete | delete movie by movieId | |
/movie/:movieId/trailer/upload | post | upload trailer by movieId | |
/movie/:movieId/trailer/delete | delete | delete trailer by movieId | |
/movie/:movieId/poster/upload | post | upload poster by movieId | |
/movie/:movieId/poster/delete | delete | delete poster by movieId | |
/comment | / | get | get comments of a movie |
/ | post | post comment to a movie | |
/ | put | update comment of a movie | |
/ | delete | delete comment of a movie | |
/movie | /history | post | add to the history of a user |
/history | delete | remove from the history of a user | |
/watchlist | post | add to the watchlist of a user | |
/watchlist | delete | remove from the watchlist of a user | |
/ | get | get a list of all movies | |
/:id | get | get details of a movie by id | |
/latest | get | get a list of all the latest movies | |
/upcoming | get | get a list of all the upcoming movies | |
/featured | get | get a list of all the featured movies by the admin | |
/filter | get | filter all the movies shown by genres, languages and ratings | |
/watch | post | get the link to watch the movie | |
/otp | /generate | post | generate the otp for the specified phoneNumber or the email and send it through the respective service |
/verify | post | verify the otp specified by the user | |
/password | /forgot | post | send the password reset link to the email |
/reset | post | resets the password | |
/valid-token | post | to prevent the user from accessing the reset password route by verifying the validity of the token in the params | |
/payment | /link | post | generates the payment link |
/verification | post | verifies the payment | |
/plan | / | get | get a list of subscription plans |
/:id | get | get the particular subscription plan by id | |
/search | /semantic | get | to enable the users to search semantically |
/searchOnEnter | get | to get the movies based on the search button submission | |
/autocomplete | get | for the autocomplete feature on the search bar | |
/user | /register | post | to register the user |
/login | post | to login the user | |
/logout | get | to logout the user and delete the token present in the database | |
/profile | get | to get the details of the given user | |
/profile | put | to update the details of the given user |