A comprehensive RESTful API for managing movies and users, built with Node.js, Express, and MongoDB. This backend service provides JWT-based authentication, user management, and movie database operations with complete JSDoc documentation.
git clone https://github.com/CreativeMarkus/movie_api.git
cd movie_api
npm install
Create a .env file in the root directory:
cp .env.example .env # If example exists, or create manually
Edit .env with your MongoDB connection string and JWT secret:
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
PORT=8080
| Variable | Description | Required | Default |
|---|---|---|---|
MONGODB_URI |
MongoDB connection string | Yes | - |
JWT_SECRET |
Secret key for JWT token signing | Yes | your_jwt_secret |
PORT |
Server port | No | 8080 |
npm run dev # Uses nodemon for auto-restart
npm start # Standard node server
The server will start on http://localhost:8080 (or your specified PORT).
This project includes comprehensive JSDoc documentation for all API endpoints, models, and modules.
Option 1: Generate and Open
npm run docs:open # Generates docs and opens in browser
Option 2: Generate Only
npm run docs # Generates documentation in docs/ folder
Option 3: Manual
jsdoc -c jsdoc.conf.json # Using JSDoc directly
The generated documentation includes:
docs/index.htmldocs/module-auth.htmldocs/module-routes_movies.htmldocs/module-routes_users.htmldocs/module-routes_genres.htmldocs/module-routes_directors.htmldocs/module-models.htmlPOST /login - User login (returns JWT token)POST /users - Register new userGET /users/:username - Get user details (authenticated)PUT /users/:username - Update user information (authenticated)DELETE /users/:username - Delete user account (authenticated)POST /users/:username/favorites/:movieId - Add movie to favorites (authenticated)DELETE /users/:username/favorites/:movieId - Remove movie from favorites (authenticated)GET /movies - Get all movies (authenticated)GET /movies/:id - Get specific movie by ID (authenticated)GET /movies/search?q=query - Search movies by title (authenticated)GET /movies/genre/:genre - Get movies by genre (authenticated)GET /movies/director/:director - Get movies by director (authenticated)GET /movies/year/:year - Get movies by year (authenticated)POST /movies - Add new movie (authenticated)PUT /movies/:id - Update movie (authenticated)DELETE /movies/:id - Delete movie (authenticated)GET /directors - Get all directorsGET /directors/:id - Get specific directorPOST /directors - Add new directorPUT /directors/:id - Update directorDELETE /directors/:id - Delete directorGET /genres - Get all genresGET /genres/:id - Get specific genrePOST /genres - Add new genrePUT /genres/:id - Update genreDELETE /genres/:id - Delete genreGET / - Welcome messageGET /documentation - API documentation (HTML)docs/index.htmlnpm run docs:open to generate and view documentationThis API uses JWT (JSON Web Tokens) for authentication. Most endpoints require a valid JWT token.
POST /usersPOST /loginInclude the JWT token in the Authorization header:
Authorization: Bearer <your_jwt_token>
curl -X POST http://localhost:8080/login \
-H "Content-Type: application/json" \
-d '{
"Username": "testuser",
"Password": "password123"
}'
movie_api/
├── docs/ # Generated JSDoc documentation
├── models/ # Mongoose schemas
│ ├── movies.js # Movie model
│ ├── users.js # User model
│ ├── directors.js # Director model
│ └── genres.js # Genre model
├── routes/ # Express route handlers
│ ├── movies.js # Movie routes
│ ├── users.js # User routes
│ ├── directors.js # Director routes
│ └── genres.js # Genre routes
├── public/ # Static files
│ ├── index.html # Home page
│ └── documentation.html # API documentation
├── logs/ # Log files
├── auth.js # Authentication logic
├── passport.js # Passport strategies
├── server.js # Main server file
├── models.js # Centralized models export
├── jsdoc.conf.json # JSDoc configuration
├── API_README.md # Additional API documentation
├── package.json # Dependencies and scripts
├── .env # Environment variables
├── Procfile # Heroku deployment config
└── README.md # Project documentation
├── models.js # Centralized models export ├── package.json # Dependencies and scripts ├── .env # Environment variables ├── Procfile # Heroku deployment config └── README.md # Project documentation
---
## Technologies Used
- **Backend Framework**: Express.js
- **Database**: MongoDB with Mongoose ODM
- **Authentication**: Passport.js with JWT strategy
- **Password Hashing**: bcrypt
- **HTTP Logging**: Morgan
- **CORS**: cors middleware
- **Environment Variables**: dotenv
- **Development**: nodemon for auto-restart
- **Documentation**: JSDoc with comprehensive API documentation
- **Code Comments**: Extensive inline and block comments throughout
---
## Deployment
### Heroku
This app is configured for Heroku deployment with the included `Procfile`.
1. **Create Heroku app**
```bash
heroku create your-app-name
heroku config:set MONGODB_URI=your_mongodb_uri
heroku config:set JWT_SECRET=your_jwt_secret
git push heroku main
The app can be deployed on any Node.js hosting platform. Ensure environment variables are properly configured.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the ISC License. See the LICENSE file for details.
CreativeMarkus - GitHub Profile
If you encounter any issues or have questions, please open an issue on GitHub.