This project is a summary of the ALX back-end trimester, covering essential concepts like authentication, NodeJS, MongoDB, Redis, pagination, and background processing. The objective is to build a simple platform to upload and view files with the following features:
-
User authentication via a token
-
List all files
-
Upload a new file
-
Change permission of a file
-
View a file
-
Generate thumbnails for images
This project is designed for learning purposes to assemble each piece and build a full product.
- Features
- Concepts Covered
- Project Structure
- Setup
- Usage
- API Documentation
- Technologies
- License
- Authors
-
User Authentication: Users can authenticate via tokens.
-
File Management:
-
List all files
-
Upload new files
-
Change file permissions
-
View files
-
Generate thumbnails for images
-
-
Creating an API with Express: Learn how to set up and manage routes, handle requests and responses, and create a robust API using Express.js.
-
User Authentication: Implement token-based authentication to secure the platform.
-
Data Storage in MongoDB: Store and manage file data in MongoDB.
-
Temporary Data Storage in Redis: Use Redis for caching and temporary data storage.
-
Background Processing: Set up and use a background worker for tasks like generating thumbnails for images.
This is an initial template, probably will be changed later.
├── src
│ ├── controllers
│ ├── models
│ ├── routes
│ ├── services
│ ├── workers
│ ├── app.js
│ └── server.js
├── .env.example
├── .gitignore
├── package.json
├── README.md
└── tests
src/controllers
: Contains the controller logic for handling requests.src/models
: Contains Mongoose schemas for MongoDB.src/routes
: Defines the API endpoints.src/services
: Contains business logic and utilities.src/workers
: Contains background worker scripts.src/app.js
: Main application setup.src/server.js
: Server configuration and startup..env.example
: Example environment variables file.tests
: Contains test cases for the application.
- Node.js
- MongoDB
- Redis
- Clone the repository:
git clone --depth=1 https://github.com/Davenchy/alx-files_manager.git
cd alx-files_manager
- Install dependencies:
npm install
# or using bun node package manager
bun install
- Set up environment variables:
Rename the .env.example
file to .env
and update the values accordingly.
- Start MongoDB and Redis servers:
Make sure MongoDB and Redis are running on your system.
- Start the application:
npm start
To start the server, use:
npm start
The server will run on http://localhost:3000
by default.
To run the tests, use:
npm test
POST /api/register
: Register a new userPOST /api/login
: Authenticate a userGET /api/data
: Retrieve data from MongoDBPOST /api/data
: Store data in MongoDBGET /api/temp-data
: Retrieve temporary data from RedisPOST /api/temp-data
: Store temporary data in Redis
- Express.js: Web framework for Node.js
- MongoDB: NoSQL database for data storage
- Redis: In-memory data structure store for temporary data
- Node.js: JavaScript runtime environment
- Mongoose: ODM for MongoDB
- Bull: Redis-based queue for background jobs
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to reach out if you have any questions or need further assistance. Happy coding!