The server-side code for the Movie List application. This server provides the necessary backend functionality to support the client-side application, allowing users to browse and manage their favorite movies. You can download client-side code here
To get started, first, you need git and Node.js installed, and to create the MongoDB database.
-
Clone the repository:
git clone https://github.com/darkeris345/Movies-List-server.git
-
Navigate to the repository directory:
cd Movies-List-server
-
Install dependencies:
npm i
-
Run the server:
npm start
-
Create a MongoDB account if you don't have one:MongoDB Atlas for more details.
-
Create a MongoDB database and give it the name you want.
-
Create a .env file in this project and add your database details. Here is an example:
NODE_ENV=development
PORT=3000
DATABASE_URL=mongodb+srv://<USERNAME>:<PASSWORD>@tours.fpc6858.mongodb.net/<DATABASE_NAME>?retryWrites=true&w=majority
JWT_SECRET=YOUR_JWT_SECRET_KEY
- There is an import.js file in the root folder, use it to upload moviesDB.movies.json file to your database. You can upload JSON files to the database manually or use import.js.
node import.js --import
if you want to delete all data from the database:
node import.js --delete
There are two types of users: Admin and User. Admin users can additionally add, edit, and remove movies from the movie list. Users have only read-only access to the movie list, they can only view the list, add those movies to their favorite list, and remove them.
To add an admin type, you can use Postman to make a POST request to your authentication endpoint when registering a new user. Provide the following JSON payload in the request body:
{
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"type": "admin"
}