Skip to content

This repository contains the back-end implementation of a files manager system developed as a project for learning..

Notifications You must be signed in to change notification settings

Reliccode/alx-files_manager

Repository files navigation

README.md

0x04. Files manager

Files Manager is a file management application built with Node.js, Express.js, MongoDB, and Redis. It provides a RESTful API for managing files, users, authentication, and file metadata.

Features

  • User authentication using JWT (JSON Web Tokens)
  • File upload and storage
  • File metadata management
  • File publishing and unpublishing
  • Image thumbnail generation
  • Redis caching for improved performance

Resources

Read or watch:

Learning Objectives

  • how to create an API with Express
  • how to authenticate a user
  • how to store data in MongoDB
  • how to store temporary data in Redis
  • how to set up and use a background worker

Requirements

  • Editor: I used Visual Studio Code, you may use Vi, Vim, Emacs, or any other preferred editor.
  • All files will be interpreted/compiled on Ubuntu 18.04 LTS using node (version 12.x.x)
  • All files should end with a new line

Here are the tasks and corresponding files with links to the repository:

Tasks

  1. Redis utils

  2. MongoDB utils

  3. First API

  4. Create a new user

  5. Authenticate a user

  6. First file

  7. Get and list file

  8. File publish/unpublish

  9. File data

  10. Image Thumbnails

This structure should help navigate the repository and locate specific files related to each task.

Project Structure

  • utils/: Contains utility classes for Redis and MongoDB.
  • routes/: Contains route definitions.
  • controllers/: Contains controller logic for handling requests.
  • worker.js: Worker script for processing background tasks.
  • package.json: Configuration file for Node.js dependencies.
  • .eslintrc.js: ESLint configuration file.
  • babel.config.js: Babel configuration file.

Installation

  1. Clone the repository:
git clone https://github.com/Reliccode/alx-files_manager.git
  1. Install dependencies:
cd alx-files_manager
npm install
  1. Set up environment variables:

Create a '.env' file in the root directory and specify the following variables:

PORT=3000
MONGO_URI=mongodb://localhost:27017/alx-files-manager
JWT_SECRET=your_jwt_secret
REDIS_HOST=localhost
REDIS_PORT=6379

Make sure to replace your_jwt_secret with your desired JWT secret key.

  1. Run the application (Start the server):
npm start

Usage

The API endpoints can be accessed using tools like curl or Postman.

For example, to authenticate a user:

curl 0.0.0.0:5000/connect -H "Authorization: Basic Ym9iQGR5bGFuLmNvbTp0b3RvMTIzNCE="

API Endpoints

  • Users
    • POST /api/users/register: Register a new user
    • POST /api/users/login: Authenticate a user
  • Files
    • POST /api/files/upload: Upload a file
    • GET /api/files/:id: Get file metadata by ID
    • GET /api/files/:id/data: Get file data by ID
    • PUT /api/files/:id/publish: Publish a file
    • PUT /api/files/:id/unpublish: Unpublish a file
    • GET /api/files/:id/thumbnail: Get image thumbnail by ID

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Naniwet Maritim

About

This repository contains the back-end implementation of a files manager system developed as a project for learning..

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages