A robust backend API for a file management system built with Node.js. This project implements user authentication, file upload/download functionality, permissions management, and image thumbnail generation.
-
User Authentication
- Basic authentication (Base64)
- Token-based access
- Session management with Redis
-
File Operations
- Upload files (regular files & images)
- Create folders
- List files & folders
- Get file data
- Set file permissions (public/private)
- File parent/child relationships
-
Image Processing
- Automatic thumbnail generation
- Multiple thumbnail sizes (100px, 250px, 500px)
- Background processing with Bull
-
Database Management
- MongoDB for data persistence
- Redis for caching & session management
- Pagination support
- Backend: Node.js with Express
- Databases:
- MongoDB (file/user data storage)
- Redis (caching, session management)
- Image Processing: image-thumbnail
- Queue System: Bull
- Testing: Mocha
- Development: ESLint, Nodemon
- Clone the repository:
git clone https://github.com/your-username/alx-files_manager.git
cd alx-files_manager
- Install dependencies:
npm install
- Set up environment variables:
# Create .env file
cp .env.example .env
# Configure these variables
DB_HOST=localhost
DB_PORT=27017
DB_DATABASE=files_manager
FOLDER_PATH=/tmp/files_manager
- Start the servers:
# Start the API server
npm run start-server
# Start the worker (in a separate terminal)
npm run start-worker
GET /connect
- Sign-in with Basic AuthGET /disconnect
- Sign-out based on tokenGET /users/me
- Get user info based on token
POST /users
- Create a new userGET /status
- Get API statusGET /stats
- Get file & user stats
POST /files
- Upload a new file/create folderGET /files/:id
- Get file by IDGET /files
- List all files (with pagination)PUT /files/:id/publish
- Make file publicPUT /files/:id/unpublish
- Make file privateGET /files/:id/data
- Get file data (supports thumbnail sizes)
Run the test suite:
npm test
Tests cover:
- Redis client functionality
- Database client functionality
- API endpoints
- Worker processes
alx-files_manager/
├── controllers/
│ ├── AppController.js
│ ├── AuthController.js
│ ├── FilesController.js
│ └── UsersController.js
├── routes/
│ └── index.js
├── utils/
│ ├── db.js
│ └── redis.js
├── worker.js
├── server.js
└── tests/
- Fork the repository
- Create your feature branch (
git checkout -b feature/awesome-feature
) - Commit your changes (
git commit -m 'Add awesome feature'
) - Push to the branch (
git push origin feature/awesome-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Original Author: [https://x.com/SerMachage]
- ALX & Holberton School for the project requirements and support
- Node.js community for excellent documentation
- All contributors and testers