A RESTful API for an imaginary movie rental service, built with Node.js, Express, and MongoDB.
- Movie and genre management
- Customer management
- Rental tracking with return processing
- JWT-based authentication and authorization
- Input validation with Joi
- Structured logging with Winston (console + MongoDB transport)
- HTTP request logging with Morgan
- Security hardening with Helmet
- Automated tests with Jest and Supertest
| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express |
| Database | MongoDB (via Mongoose) |
| Auth | JSON Web Tokens + bcrypt |
| Validation | Joi |
| Logging | Winston, Winston-MongoDB, Morgan |
| Security | Helmet |
| Testing | Jest, Supertest |
vidly-app/
├── config/ # Environment-specific configuration
├── middleware/ # Custom Express middleware (auth, error handling, etc.)
├── models/ # Mongoose schemas and models
├── routes/ # Express route handlers
├── startup/ # App initialization (db, logging, routes, config)
├── tests/ # Integration and unit tests
└── index.js # Entry point
- Node.js v18+
- MongoDB instance (local or Atlas)
- Clone the repo
git clone https://github.com/IsmailSamirIbrahim/vidly-app.git
cd vidly-app- Install dependencies
npm install- Configure environment
Create configuration files under config/ for your environment. At minimum, set:
db— MongoDB connection stringjwtPrivateKey— secret key for signing JWTs
Example using the config package (config/default.json):
{
"db": "mongodb://localhost/vidly",
"jwtPrivateKey": "your_secret_key"
}- Run the server
node index.jsOr with auto-reload via nodemon:
npx nodemon index.jsThe API will be available at http://localhost:3000 by default.
| Resource | Endpoint |
|---|---|
| Genres | /api/genres |
| Movies | /api/movies |
| Customers | /api/customers |
| Rentals | /api/rentals |
| Returns | /api/returns |
| Users | /api/users |
| Auth | /api/auth |
All write operations require a valid JWT passed in the x-auth-token header.
npm testRuns Jest in watch mode with verbose output and coverage reporting.
ISC