{"id":18743903,"url":"https://github.com/devmarkson/alx-files_manager","last_synced_at":"2025-11-22T00:30:13.638Z","repository":{"id":251407457,"uuid":"689159588","full_name":"DevMarkson/alx-files_manager","owner":"DevMarkson","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-09T00:34:07.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T19:47:01.327Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevMarkson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-09T00:33:52.000Z","updated_at":"2023-09-09T00:34:11.000Z","dependencies_parsed_at":"2024-08-02T20:31:38.931Z","dependency_job_id":"fbd22e95-28a1-49b0-aec9-88e3323345df","html_url":"https://github.com/DevMarkson/alx-files_manager","commit_stats":null,"previous_names":["devmarkson/alx-files_manager"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2Falx-files_manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2Falx-files_manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2Falx-files_manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2Falx-files_manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevMarkson","download_url":"https://codeload.github.com/DevMarkson/alx-files_manager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627300,"owners_count":19670844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T16:13:08.285Z","updated_at":"2025-11-22T00:30:13.060Z","avatar_url":"https://github.com/DevMarkson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Files Manager - Back-End\n\nThis project is a summary of the back-end trimester, focusing on 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:\n\n1. User authentication via a token.\n2. Listing all files.\n3. Uploading a new file.\n4. Changing permission of a file.\n5. Viewing a file.\n6. Generating thumbnails for images.\n\nYou will be guided step by step for building it, but you have some freedoms of implementation, such as splitting code into more files.\n\n## Prerequisites\n\nBefore you start, make sure you have the following set up:\n\n- Node.js installed on your system.\n- MongoDB and Redis databases set up.\n- Clone the GitHub repository\n\n## Installation\n\n1. Clone the repository to your local machine.\n\n   ```bash\n   git clone https://github.com/Markson17/alx-files_manager.git\n   ```\n\n2. Navigate to the project directory.\n\n   ```bash\n   cd alx-files_manager\n   ```\n\n3. Install the required dependencies.\n\n   ```bash\n   npm install\n   ```\n\n## Configuration\n\n### Redis Configuration\n\nInside the `utils` folder, create a file `redis.js` that contains the `RedisClient` class. Configure the connection to your Redis instance using environment variables (`DB_HOST`, `DB_PORT`, and `DB_DATABASE`).\n\n### MongoDB Configuration\n\nInside the `utils` folder, create a file `db.js` that contains the `DBClient` class. Configure the connection to your MongoDB instance using environment variables (`DB_HOST`, `DB_PORT`, and `DB_DATABASE`).\n\n### Server Configuration\n\nIn `server.js`, set the desired port for your Express server using the `PORT` environment variable.\n\n## Usage\n\n### Start the Express Server\n\n```bash\nnpm start\n```\n\n### Start the Worker for Thumbnails Generation (in a separate terminal)\n\n```bash\nnpm run start-worker\n```\n\n### API Endpoints\n\n#### 1. Get Status\n\n- **Endpoint**: `GET /status`\n- **Description**: Check if Redis and MongoDB are alive.\n- **Response**: `{ \"redis\": true, \"db\": true }`\n\n#### 2. Get Stats\n\n- **Endpoint**: `GET /stats`\n- **Description**: Get the number of users and files in the database.\n- **Response**: `{ \"users\": 12, \"files\": 1231 }`\n\n#### 3. Create a New User\n\n- **Endpoint**: `POST /users`\n- **Description**: Create a new user in the database.\n- **Request Body**:\n\n  ```json\n  {\n    \"email\": \"user@example.com\",\n    \"password\": \"password123\"\n  }\n  ```\n\n- **Response**: `{ \"id\": \"user_id\", \"email\": \"user@example.com\" }`\n\n#### 4. Authenticate a User\n\n- **Endpoint**: `GET /connect`\n- **Description**: Sign in a user by generating an authentication token.\n- **Request Header**: `Authorization: Basic base64(email:password)`\n- **Response**: `{ \"token\": \"authentication_token\" }`\n\n#### 5. Sign Out a User\n\n- **Endpoint**: `GET /disconnect`\n- **Description**: Sign out a user based on the authentication token.\n- **Request Header**: `X-Token: authentication_token`\n- **Response**: No content (204)\n\n#### 6. Get User Profile\n\n- **Endpoint**: `GET /users/me`\n- **Description**: Retrieve the user's profile based on the authentication token.\n- **Request Header**: `X-Token: authentication_token`\n- **Response**: `{ \"id\": \"user_id\", \"email\": \"user@example.com\" }`\n\n#### 7. Upload a File\n\n- **Endpoint**: `POST /files`\n- **Description**: Upload a new file to the platform.\n- **Request Header**: `X-Token: authentication_token`\n- **Request Body**:\n\n  ```json\n  {\n    \"name\": \"myFile.txt\",\n    \"type\": \"file\",\n    \"data\": \"Base64-encoded-data\"\n  }\n  ```\n\n- **Response**: `{ \"id\": \"file_id\", \"userId\": \"user_id\", \"name\": \"myFile.txt\", \"type\": \"file\", \"isPublic\": false, \"parentId\": 0 }`\n\n#### 8. List Files\n\n- **Endpoint**: `GET /files`\n- **Description**: List all user files with pagination.\n- **Request Header**: `X-Token: authentication_token`\n- **Query Parameters**:\n  - `page` (default: 0) - Page number (starts at 0).\n- **Response**: Array of file objects.\n\n#### 9. Get File Details\n\n- **Endpoint**: `GET /files/:id`\n- **Description**: Get details of a specific file.\n- **Request Header**: `X-Token: authentication_token`\n- **Response**: File details object.\n\n#### 10. Publish a File\n\n- **Endpoint**: `PUT /files/:id/publish`\n- **Description**: Set\n\n a file's permissions to public.\n- **Request Header**: `X-Token: authentication_token`\n- **Response**: Updated file details object.\n\n#### 11. Unpublish a File\n\n- **Endpoint**: `PUT /files/:id/unpublish`\n- **Description**: Set a file's permissions to private.\n- **Request Header**: `X-Token: authentication_token`\n- **Response**: Updated file details object.\n\n#### 12. Delete a File\n\n- **Endpoint**: `DELETE /files/:id`\n- **Description**: Delete a file.\n- **Request Header**: `X-Token: authentication_token`\n- **Response**: No content (204)\n\n## Testing\n\nTo run the tests, use the following command:\n\n```bash\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Falx-files_manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevmarkson%2Falx-files_manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Falx-files_manager/lists"}