diff --git a/README.md b/README.md
index e69de29..3cd4d9c 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1,109 @@
+
+
+# Chat Communications Service
+
+
+
+
+
+[![CircleCI](https://dl.circleci.com/status-badge/img/gh/ELEVATE-Project/mentoring/tree/master.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/ELEVATE-Project/mentoring/tree/master)
+[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=ELEVATE-Project_mentoring&metric=duplicated_lines_density&branch=master)](https://sonarcloud.io/summary/new_code?id=ELEVATE-Project_mentoring)
+[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ELEVATE-Project_mentoring&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ELEVATE-Project_mentoring)
+[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=ELEVATE-Project_mentoring&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=ELEVATE-Project_mentoring)
+[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
+[![Docs](https://img.shields.io/badge/Docs-success-informational)](https://elevate-docs.shikshalokam.org/mentorEd/intro)
+
+
+
+---
+
+## Overview
+
+The **Chat Communications Service** is an internal microservice designed to act as middleware between the core application services and chat platforms like [Rocket.Chat](https://rocket.chat/). It simplifies the integration, management, and scalability of chat-based communications for various use cases.
+
+### Key Features
+
+- Acts as a middleware for seamless communication with chat platforms.
+- Provides abstraction for APIs of chat services.
+- Offers extensible architecture to integrate additional chat providers in the future.
+- Ensures robust logging and error handling for chat-related operations.
+
+## Table of Contents
+
+1. [Getting Started](#getting-started)
+2. [Features](#features)
+3. [Installation](#installation)
+4. [License](#license)
+
+---
+
+## Getting Started
+
+### Prerequisites
+
+- **Node.js** (v16.x or later)
+- **PostgreSQL** for any required database operations.
+- Access to a configured [Rocket.Chat](https://rocket.chat/) server.
+
+### Installation
+
+1. Clone the repository:
+
+ ```
+ git clone https://github.com/ELEVATE-Project/chat-communications.git
+ cd chat-communications
+ ```
+
+2. Install dependencies:
+
+ ```
+ npm install
+ ```
+
+3. Set up environment variables:
+ Create a `.env` file with the following configurations:
+
+ ```
+ CHAT_PLATFORM_URL=
+ CHAT_PLATFORM_ADMIN_EMAIL=
+ CHAT_PLATFORM_ADMIN_USER_ID=
+ CHAT_PLATFORM_ACCESS_TOKEN=
+ INTERNAL_ACCESS_TOKEN=
+ DEV_DATABASE_URL=
+ USERNAME_HASH_SALT=
+ PASSWORD_HASH_SALT=
+
+ ```
+
+4. Run migrations:
+
+ ```
+ npx sequelize-cli db:migrate
+ ```
+
+5. Start the service:
+ ```
+ npm start
+ ```
+
+---
+
+## Features
+
+- **Chat Integration:** Unified interface to interact with chat platforms.
+- **User Management:** Create, delete, and manage chat users programmatically.
+- **Room Management:** Automate chat room creation and management.
+- **Message Handling:** Send and receive messages with structured APIs.
+- **Extensibility:** Easily add support for new chat providers.
+
+---
+
+## License
+
+This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). See the [LICENSE](LICENSE) file for details.
+
+---
diff --git a/src/api-doc/MentorED-Communications.postman_collection.json b/src/api-doc/MentorED-Communications.postman_collection.json
new file mode 100644
index 0000000..e9d3bf5
--- /dev/null
+++ b/src/api-doc/MentorED-Communications.postman_collection.json
@@ -0,0 +1,1096 @@
+{
+ "info": {
+ "_postman_id": "51debeb8-948d-4d90-97a6-622d6e844ddd",
+ "name": "MentorED-Communications",
+ "description": "# MentorED-Communications API Documentation\n\nThe MentorED-Communications service acts as middleware between your application and communication platforms (currently, only RocketChat is supported). Below are the available features and their corresponding API endpoints for interacting with the service.\n\n## Available Features\n\n### 1\\. **User Signup**\n\nThis feature allows you to register a new user for the communication platform. When you sign up a user, their details such as user ID, name, and email are stored in the communication system, enabling them to interact with the chat service.\n\n- **Endpoint**: `POST /communications/v1/communication/signup`\n \n- **Description**: Registers a new user with their basic details.\n \n- **Required Fields**:\n \n - `user_id`: Unique identifier for the user (e.g., UUID).\n \n - `name`: The name of the user.\n \n - `email`: The user's email address.\n \n\n### 2\\. **User Login**\n\nThis feature allows an existing user to log into the communication service. Upon login, the user is authenticated, and a session is established to interact with the chat platform.\n\n- **Endpoint**: `POST /communications/v1/communication/login`\n \n- **Description**: Logs a user into the communication system using their unique user ID.\n \n- **Required Fields**:\n \n - `user_id`: The unique identifier for the user who is logging in.\n \n\n### 3\\. **User Logout**\n\nThe logout functionality allows users to log out from the communication service. This will end the user's active session and disconnect them from the chat platform.\n\n- **Endpoint**: `POST /communications/v1/communication/logout`\n \n- **Description**: Logs the user out of the communication service.\n \n- **Required Fields**:\n \n - `user_id`: The unique identifier of the user who wishes to log out.\n \n\n### 4\\. **Create Communication Room**\n\nThis feature enables you to create a new communication room (chat group) between two or more users. A room can be initialized with a welcome or introductory message to start the conversation.\n\n- **Endpoint**: `POST /communications/v1/communication/createRoom`\n \n- **Description**: Creates a new room for communication between specified users.\n \n- **Required Fields**:\n \n - `usernames`: An array of user IDs who should be added to the room.\n \n - `initial_message`: A message that will be sent when the room is created (optional).\n \n\n### 5\\. **Update Avatar**\n\nUsers can update their profile picture (avatar) on the communication platform using this feature. The new avatar is represented by an image URL.\n\n- **Endpoint**: `POST /communications/v1/communication/updateAvatar`\n \n- **Description**: Updates the user's avatar with a new image URL.\n \n- **Required Fields**:\n \n - `user_id`: The unique identifier for the user whose avatar is being updated.\n \n - `image_url`: The URL of the new image to be used as the avatar.\n \n\n### 6\\. **Update User Information**\n\nThis feature allows you to update the personal details of an existing user. This can include changes to the user's name or other profile information.\n\n- **Endpoint**: `POST /communications/v1/communication/updateUser`\n \n- **Description**: Updates a user's details (e.g., their name) in the communication service.\n \n- **Required Fields**:\n \n - `user_id`: The unique identifier of the user whose information is being updated.\n \n - `name`: The new name for the user.\n \n\n## Authentication\n\nTo use these endpoints, an `internal_access_token` is required in the request header. This token authenticates the user and ensures that only authorized users can access the communication service.\n\n## To Use:\n\n1. Replace any placeholders (like `user_id`, `name`, `image_url`, etc.) with actual values based on your use case.\n \n2. Ensure the `internal_access_token` header is provided for authentication.\n \n3. You can use these features in combination to manage users, rooms, and their profiles on the communication platform.\n \n\n## Future Enhancements\n\n- **Support for additional communication services**: Currently, the system supports RocketChat, but there are plans to integrate other chat services in the future.\n \n- **Advanced messaging features**: Future versions will support sending and receiving messages, multimedia attachments, and message history.\n \n\n---\n\n### Disclaimer:\n\nThe API endpoints described here are meant for internal communication purposes and might evolve as more services are added. Be sure to keep an eye on version updates to stay informed about any changes in the API or its features.",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
+ "_exporter_id": "21498549"
+ },
+ "item": [
+ {
+ "name": "Signup",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript",
+ "packages": {}
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"John Doe\",\n \"email\": \"johndoe@example.com\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/signup",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "signup"
+ ]
+ },
+ "description": "This endpoint registers a new user with their unique identifier (`user_id`), name, and email. It initializes the user’s profile in the communication service, allowing them to use the platform for messaging and other interactions."
+ },
+ "response": [
+ {
+ "name": "201 Created - User Created",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"John Doe\",\n \"email\": \"johndoe@example.com\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/signup",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "signup"
+ ]
+ }
+ },
+ "status": "Created",
+ "code": 201,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "120"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"78-4nIEFQCjGsZ7KcWgd4PrnUDiZfY\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:16:45 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"OK\",\n \"message\": \"User has been successfully created.\",\n \"result\": {\n \"user_id\": \"GnrxwdtvTwQafKagQ\"\n },\n \"meta\": {}\n}"
+ },
+ {
+ "name": "409 Conflict - User Exists",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"John Doe\",\n \"email\": \"johndoe@example.com\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/signup",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "signup"
+ ]
+ }
+ },
+ "status": "Conflict",
+ "code": 409,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "103"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"67-+NtCnOyXErR2OR1egPJKZkdTOO0\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:26:16 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"SERVER_ERROR\",\n \"error\": [],\n \"meta\": {},\n \"message\": \"The user already exists in the system.\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Login",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript",
+ "packages": {}
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/login",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "login"
+ ]
+ },
+ "description": "This endpoint logs a user into the communication service using their unique `user_id`. Upon successful login, the user can start interacting with the chat platform. This session remains active until the user logs out or the session expires."
+ },
+ "response": [
+ {
+ "name": "200 OK - Request Successful",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/login",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "login"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "176"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"b0-f/p9BDapZL3+qneQ9WZCUncW1Rc\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:31:59 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"OK\",\n \"message\": \"User has successfully logged in.\",\n \"result\": {\n \"user_id\": \"GnrxwdtvTwQafKagQ\",\n \"auth_token\": \"2r1CXIEdtVlDbymeJVbWuHz3j-TI9aNkUa1JbkVneaw\"\n },\n \"meta\": {}\n}"
+ },
+ {
+ "name": "401 Unauthorized - Invalid Credentials",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614c174000\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/login",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "login"
+ ]
+ }
+ },
+ "status": "Unauthorized",
+ "code": 401,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "85"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"55-bq9UPofo1odyXsLbE5GOzKUQvvU\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:34:39 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"UNAUTHORIZED\",\n \"error\": [],\n \"meta\": {},\n \"message\": \"Unauthorized request\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Logout",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript",
+ "packages": {}
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/logout",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "logout"
+ ]
+ },
+ "description": "This endpoint logs the user out of the communication service. It invalidates the active session associated with the provided `user_id`, effectively disconnecting the user from the chat platform and preventing further interactions until they log in again."
+ },
+ "response": [
+ {
+ "name": "200 OK - Request Successful",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/logout",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "logout"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "152"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"98-48uTvNHIaatSYWqyXePw+EdMh8Y\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:36:35 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"OK\",\n \"message\": \"User has successfully logged out.\",\n \"result\": {\n \"status\": \"success\",\n \"data\": {\n \"message\": \"You've been logged out!\"\n }\n },\n \"meta\": {}\n}"
+ },
+ {
+ "name": "Logout",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000c\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/logout",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "logout"
+ ]
+ }
+ },
+ "status": "Unauthorized",
+ "code": 401,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "85"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"55-bq9UPofo1odyXsLbE5GOzKUQvvU\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:37:14 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"UNAUTHORIZED\",\n \"error\": [],\n \"meta\": {},\n \"message\": \"Unauthorized request\"\n}"
+ },
+ {
+ "name": "404 Not Found - User Not Found",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000c\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/logout",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "logout"
+ ]
+ }
+ },
+ "status": "Not Found",
+ "code": 404,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "99"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"63-hsTctVopqYZwqJjdgH0UxKUYzl8\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:39:25 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"SERVER_ERROR\",\n \"error\": [],\n \"meta\": {},\n \"message\": \"The specified user does not exist.\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Create Room",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript",
+ "packages": {}
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"usernames\": [\n \"8\",\n \"1\"\n ],\n \"initial_message\": \"Hi, i would like to connect with you!\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/createRoom",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "createRoom"
+ ]
+ },
+ "description": "This endpoint creates a new communication room (chat group) between specified users, identified by their `usernames`. An initial message can be sent to start the conversation in the newly created room. This feature is ideal for setting up one-on-one or group chats in the communication system."
+ },
+ "response": [
+ {
+ "name": "200 OK - Request Successful",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"usernames\": [\n \"123e4567-e89b-12d3-a456-426614174001\",\n \"123e4567-e89b-12d3-a456-426614174000\"\n ],\n \"initial_message\": \"Hi, i would like to connect with you!\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/createRoom",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "createRoom"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "151"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"97-/0DH8JL1BxuUTEty756NTgyhd1w\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:55:40 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"OK\",\n \"message\": \"Chat room has been successfully updated.\",\n \"result\": {\n \"room\": {\n \"room_id\": \"GnrxwdtvTwQafKagQxqwyRKLfPq7huvT6K\"\n }\n },\n \"meta\": {}\n}"
+ },
+ {
+ "name": "400 Bad Request",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"usernames\": [\n \"123e4567-e89b-12d3-a456-426614174001\",\n \"123e4567-e89b-12d3-a456-426614174003\"\n ],\n \"initial_message\": \"Hi, i would like to connect with you!\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/createRoom",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "createRoom"
+ ]
+ }
+ },
+ "status": "Bad Request",
+ "code": 400,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "78"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"4e-5PpHgjWZVUEtohNZKPP43yC7eGI\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:56:11 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"CLIENT_ERROR\",\n \"error\": [],\n \"meta\": {},\n \"message\": \"invalid-users\"\n}"
+ }
+ ]
+ },
+ {
+ "name": "Set Avatar",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript",
+ "packages": {}
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"image_url\": \"https://picsum.photos/200/200\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/updateAvatar",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "updateAvatar"
+ ]
+ },
+ "description": "This endpoint allows a user to update their profile picture (avatar) by providing a new image URL. It is useful for personalizing the user's profile within the communication platform, ensuring the avatar image is reflected across their interactions."
+ },
+ "response": [
+ {
+ "name": "200 OK - Request Successful",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"image_url\": \"https://picsum.photos/200/200\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/updateAvatar",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "updateAvatar"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "114"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"72-ID4tJzG2GKkaUGtKUhq8Ui1dZKk\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:57:25 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"OK\",\n \"message\": \"Profile image has been updated successfully.\",\n \"result\": {\n \"success\": true\n },\n \"meta\": {}\n}"
+ }
+ ]
+ },
+ {
+ "name": "Update user",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript",
+ "packages": {}
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"Abel\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/updateUser",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "updateUser"
+ ]
+ },
+ "description": "This endpoint updates a user’s personal information, such as their name. It enables the modification of a user's profile details to keep them accurate and up-to-date in the communication system."
+ },
+ "response": [
+ {
+ "name": "200 OK - Request Successful",
+ "originalRequest": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"John\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}communications/v1/communication/updateUser",
+ "host": [
+ "{{base_url}}communications"
+ ],
+ "path": [
+ "v1",
+ "communication",
+ "updateUser"
+ ]
+ }
+ },
+ "status": "OK",
+ "code": 200,
+ "_postman_previewlanguage": "json",
+ "header": [
+ {
+ "key": "X-Powered-By",
+ "value": "Express"
+ },
+ {
+ "key": "Access-Control-Allow-Origin",
+ "value": "*"
+ },
+ {
+ "key": "Content-Language",
+ "value": "en"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json; charset=utf-8"
+ },
+ {
+ "key": "Content-Length",
+ "value": "113"
+ },
+ {
+ "key": "ETag",
+ "value": "W/\"71-LgBVo91hr6UG/g93DebfNSoMkvs\""
+ },
+ {
+ "key": "Date",
+ "value": "Wed, 04 Dec 2024 08:58:06 GMT"
+ },
+ {
+ "key": "Connection",
+ "value": "keep-alive"
+ },
+ {
+ "key": "Keep-Alive",
+ "value": "timeout=5"
+ }
+ ],
+ "cookie": [],
+ "body": "{\n \"responseCode\": \"OK\",\n \"message\": \"User details has been successfully updated.\",\n \"result\": {\n \"success\": true\n },\n \"meta\": {}\n}"
+ }
+ ]
+ }
+ ],
+ "auth": {
+ "type": "apikey",
+ "apikey": [
+ {
+ "key": "value",
+ "value": "internal_access_token",
+ "type": "string"
+ },
+ {
+ "key": "key",
+ "value": "internal_access_token",
+ "type": "string"
+ }
+ ]
+ },
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ ""
+ ]
+ }
+ },
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ ""
+ ]
+ }
+ }
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "1"
+ },
+ {
+ "key": "base_url",
+ "value": "http://localhost:3123/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/api-doc/api-doc.yaml b/src/api-doc/api-doc.yaml
index e69de29..09ae7d0 100644
--- a/src/api-doc/api-doc.yaml
+++ b/src/api-doc/api-doc.yaml
@@ -0,0 +1,1078 @@
+openapi: 3.0.3
+info:
+ title: MentorED-Communications
+ description: >-
+ # MentorED-Communications API Documentation
+
+
+ The MentorED-Communications service acts as middleware between your
+ application and communication platforms (currently, only RocketChat is
+ supported). Below are the available features and their corresponding API
+ endpoints for interacting with the service.
+
+
+ ## Available Features
+
+
+ ### 1\. **User Signup**
+
+
+ This feature allows you to register a new user for the communication
+ platform. When you sign up a user, their details such as user ID, name, and
+ email are stored in the communication system, enabling them to interact with
+ the chat service.
+
+
+ - **Endpoint**: `POST /communications/v1/communication/signup`
+
+ - **Description**: Registers a new user with their basic details.
+
+ - **Required Fields**:
+
+ - `user_id`: Unique identifier for the user (e.g., UUID).
+
+ - `name`: The name of the user.
+
+ - `email`: The user's email address.
+
+
+ ### 2\. **User Login**
+
+
+ This feature allows an existing user to log into the communication service.
+ Upon login, the user is authenticated, and a session is established to
+ interact with the chat platform.
+
+
+ - **Endpoint**: `POST /communications/v1/communication/login`
+
+ - **Description**: Logs a user into the communication system using their
+ unique user ID.
+
+ - **Required Fields**:
+
+ - `user_id`: The unique identifier for the user who is logging in.
+
+
+ ### 3\. **User Logout**
+
+
+ The logout functionality allows users to log out from the communication
+ service. This will end the user's active session and disconnect them from
+ the chat platform.
+
+
+ - **Endpoint**: `POST /communications/v1/communication/logout`
+
+ - **Description**: Logs the user out of the communication service.
+
+ - **Required Fields**:
+
+ - `user_id`: The unique identifier of the user who wishes to log out.
+
+
+ ### 4\. **Create Communication Room**
+
+
+ This feature enables you to create a new communication room (chat group)
+ between two or more users. A room can be initialized with a welcome or
+ introductory message to start the conversation.
+
+
+ - **Endpoint**: `POST /communications/v1/communication/createRoom`
+
+ - **Description**: Creates a new room for communication between specified
+ users.
+
+ - **Required Fields**:
+
+ - `usernames`: An array of user IDs who should be added to the room.
+
+ - `initial_message`: A message that will be sent when the room is created (optional).
+
+
+ ### 5\. **Update Avatar**
+
+
+ Users can update their profile picture (avatar) on the communication
+ platform using this feature. The new avatar is represented by an image URL.
+
+
+ - **Endpoint**: `POST /communications/v1/communication/updateAvatar`
+
+ - **Description**: Updates the user's avatar with a new image URL.
+
+ - **Required Fields**:
+
+ - `user_id`: The unique identifier for the user whose avatar is being updated.
+
+ - `image_url`: The URL of the new image to be used as the avatar.
+
+
+ ### 6\. **Update User Information**
+
+
+ This feature allows you to update the personal details of an existing user.
+ This can include changes to the user's name or other profile information.
+
+
+ - **Endpoint**: `POST /communications/v1/communication/updateUser`
+
+ - **Description**: Updates a user's details (e.g., their name) in the
+ communication service.
+
+ - **Required Fields**:
+
+ - `user_id`: The unique identifier of the user whose information is being updated.
+
+ - `name`: The new name for the user.
+
+
+ ## Authentication
+
+
+ To use these endpoints, an `internal_access_token` is required in the
+ request header. This token authenticates the user and ensures that only
+ authorized users can access the communication service.
+
+
+ ## To Use:
+
+
+ 1. Replace any placeholders (like `user_id`, `name`, `image_url`, etc.) with
+ actual values based on your use case.
+
+ 2. Ensure the `internal_access_token` header is provided for authentication.
+
+ 3. You can use these features in combination to manage users, rooms, and
+ their profiles on the communication platform.
+
+
+ ## Future Enhancements
+
+
+ - **Support for additional communication services**: Currently, the system
+ supports RocketChat, but there are plans to integrate other chat services in
+ the future.
+
+ - **Advanced messaging features**: Future versions will support sending and
+ receiving messages, multimedia attachments, and message history.
+
+
+ ---
+
+
+ ### Disclaimer:
+
+
+ The API endpoints described here are meant for internal communication
+ purposes and might evolve as more services are added. Be sure to keep an eye
+ on version updates to stay informed about any changes in the API or its
+ features.
+ version: 1.0.0
+ contact: {}
+servers:
+ - url: http://localhost:3123/communications
+paths:
+ /v1/communication/signup:
+ post:
+ summary: Signup
+ description: >-
+ This endpoint registers a new user with their unique identifier
+ (`user_id`), name, and email. It initializes the user’s profile in the
+ communication service, allowing them to use the platform for messaging
+ and other interactions.
+ operationId: signup
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ email:
+ type: string
+ example: johndoe@example.com
+ name:
+ type: string
+ example: John Doe
+ user_id:
+ type: string
+ example: 123e4567-e89b-12d3-a456-426614174000
+ required:
+ - email
+ - name
+ - user_id
+ examples:
+ Signup:
+ value:
+ email: johndoe@example.com
+ name: John Doe
+ user_id: 123e4567-e89b-12d3-a456-426614174000
+ responses:
+ '201':
+ description: 201 Created - User Created
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '120'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:16:45 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"78-4nIEFQCjGsZ7KcWgd4PrnUDiZfY"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: User has been successfully created.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: OK
+ result:
+ type: object
+ properties:
+ user_id:
+ type: string
+ example: GnrxwdtvTwQafKagQ
+ examples:
+ 201 Created - User Created:
+ value:
+ message: User has been successfully created.
+ meta: {}
+ responseCode: OK
+ result:
+ user_id: GnrxwdtvTwQafKagQ
+ '409':
+ description: 409 Conflict - User Exists
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '103'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:26:16 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"67-+NtCnOyXErR2OR1egPJKZkdTOO0"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ error:
+ type: array
+ items: {}
+ example: []
+ message:
+ type: string
+ example: The user already exists in the system.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: SERVER_ERROR
+ examples:
+ 409 Conflict - User Exists:
+ value:
+ error: []
+ message: The user already exists in the system.
+ meta: {}
+ responseCode: SERVER_ERROR
+ tags:
+ - Communications
+ /v1/communication/login:
+ post:
+ summary: Login
+ description: >-
+ This endpoint logs a user into the communication service using their
+ unique `user_id`. Upon successful login, the user can start interacting
+ with the chat platform. This session remains active until the user logs
+ out or the session expires.
+ operationId: login
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ user_id:
+ type: string
+ example: 123e4567-e89b-12d3-a456-426614c174000
+ required:
+ - user_id
+ examples:
+ Login:
+ value:
+ user_id: 123e4567-e89b-12d3-a456-426614c174000
+ responses:
+ '200':
+ description: 200 OK - Request Successful
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '176'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:31:59 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"b0-f/p9BDapZL3+qneQ9WZCUncW1Rc"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: User has successfully logged in.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: OK
+ result:
+ type: object
+ properties:
+ auth_token:
+ type: string
+ example: 2r1CXIEdtVlDbymeJVbWuHz3j-TI9aNkUa1JbkVneaw
+ user_id:
+ type: string
+ example: GnrxwdtvTwQafKagQ
+ examples:
+ 200 OK - Request Successful:
+ value:
+ message: User has successfully logged in.
+ meta: {}
+ responseCode: OK
+ result:
+ auth_token: 2r1CXIEdtVlDbymeJVbWuHz3j-TI9aNkUa1JbkVneaw
+ user_id: GnrxwdtvTwQafKagQ
+ '401':
+ description: 401 Unauthorized - Invalid Credentials
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '85'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:34:39 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"55-bq9UPofo1odyXsLbE5GOzKUQvvU"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ error:
+ type: array
+ items: {}
+ example: []
+ message:
+ type: string
+ example: Unauthorized request
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: UNAUTHORIZED
+ examples:
+ 401 Unauthorized - Invalid Credentials:
+ value:
+ error: []
+ message: Unauthorized request
+ meta: {}
+ responseCode: UNAUTHORIZED
+ tags:
+ - Communications
+ /v1/communication/logout:
+ post:
+ summary: Logout
+ description: >-
+ This endpoint logs the user out of the communication service. It
+ invalidates the active session associated with the provided `user_id`,
+ effectively disconnecting the user from the chat platform and preventing
+ further interactions until they log in again.
+ operationId: logout
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ user_id:
+ type: string
+ example: 123e4567-e89b-12d3-a456-426614174000c
+ required:
+ - user_id
+ examples:
+ Logout:
+ value:
+ user_id: 123e4567-e89b-12d3-a456-426614174000c
+ responses:
+ '200':
+ description: 200 OK - Request Successful
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '152'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:36:35 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"98-48uTvNHIaatSYWqyXePw+EdMh8Y"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: User has successfully logged out.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: OK
+ result:
+ type: object
+ properties:
+ data:
+ type: object
+ properties:
+ message:
+ type: string
+ example: You've been logged out!
+ status:
+ type: string
+ example: success
+ examples:
+ 200 OK - Request Successful:
+ value:
+ message: User has successfully logged out.
+ meta: {}
+ responseCode: OK
+ result:
+ data:
+ message: You've been logged out!
+ status: success
+ '401':
+ description: Logout
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '85'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:37:14 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"55-bq9UPofo1odyXsLbE5GOzKUQvvU"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ error:
+ type: array
+ items: {}
+ example: []
+ message:
+ type: string
+ example: Unauthorized request
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: UNAUTHORIZED
+ examples:
+ Logout:
+ value:
+ error: []
+ message: Unauthorized request
+ meta: {}
+ responseCode: UNAUTHORIZED
+ '404':
+ description: 404 Not Found - User Not Found
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '99'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:39:25 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"63-hsTctVopqYZwqJjdgH0UxKUYzl8"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ error:
+ type: array
+ items: {}
+ example: []
+ message:
+ type: string
+ example: The specified user does not exist.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: SERVER_ERROR
+ examples:
+ 404 Not Found - User Not Found:
+ value:
+ error: []
+ message: The specified user does not exist.
+ meta: {}
+ responseCode: SERVER_ERROR
+ tags:
+ - Communications
+ /v1/communication/createRoom:
+ post:
+ summary: Create Room
+ description: >-
+ This endpoint creates a new communication room (chat group) between
+ specified users, identified by their `usernames`. An initial message can
+ be sent to start the conversation in the newly created room. This
+ feature is ideal for setting up one-on-one or group chats in the
+ communication system.
+ operationId: createRoom
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ initial_message:
+ type: string
+ example: Hi, i would like to connect with you!
+ usernames:
+ type: array
+ items:
+ type: string
+ example: 123e4567-e89b-12d3-a456-426614174001
+ example:
+ - 123e4567-e89b-12d3-a456-426614174001
+ - 123e4567-e89b-12d3-a456-426614174003
+ required:
+ - usernames
+ - initial_message
+ examples:
+ Create Room:
+ value:
+ initial_message: Hi, i would like to connect with you!
+ usernames:
+ - 123e4567-e89b-12d3-a456-426614174001
+ - 123e4567-e89b-12d3-a456-426614174003
+ responses:
+ '200':
+ description: 200 OK - Request Successful
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '151'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:55:40 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"97-/0DH8JL1BxuUTEty756NTgyhd1w"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: Chat room has been successfully updated.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: OK
+ result:
+ type: object
+ properties:
+ room:
+ type: object
+ properties:
+ room_id:
+ type: string
+ example: GnrxwdtvTwQafKagQxqwyRKLfPq7huvT6K
+ examples:
+ 200 OK - Request Successful:
+ value:
+ message: Chat room has been successfully updated.
+ meta: {}
+ responseCode: OK
+ result:
+ room:
+ room_id: GnrxwdtvTwQafKagQxqwyRKLfPq7huvT6K
+ '400':
+ description: 400 Bad Request
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '78'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:56:11 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"4e-5PpHgjWZVUEtohNZKPP43yC7eGI"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ error:
+ type: array
+ items: {}
+ example: []
+ message:
+ type: string
+ example: invalid-users
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: CLIENT_ERROR
+ examples:
+ 400 Bad Request:
+ value:
+ error: []
+ message: invalid-users
+ meta: {}
+ responseCode: CLIENT_ERROR
+ tags:
+ - Communications
+ /v1/communication/updateAvatar:
+ post:
+ summary: Set Avatar
+ description: >-
+ This endpoint allows a user to update their profile picture (avatar) by
+ providing a new image URL. It is useful for personalizing the user's
+ profile within the communication platform, ensuring the avatar image is
+ reflected across their interactions.
+ operationId: setAvatar
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ image_url:
+ type: string
+ example: https://picsum.photos/200/200
+ user_id:
+ type: string
+ example: 123e4567-e89b-12d3-a456-426614174000
+ required:
+ - image_url
+ - user_id
+ examples:
+ Set Avatar:
+ value:
+ image_url: https://picsum.photos/200/200
+ user_id: 123e4567-e89b-12d3-a456-426614174000
+ responses:
+ '200':
+ description: 200 OK - Request Successful
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '114'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:57:25 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"72-ID4tJzG2GKkaUGtKUhq8Ui1dZKk"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: Profile image has been updated successfully.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: OK
+ result:
+ type: object
+ properties:
+ success:
+ type: boolean
+ example: true
+ examples:
+ 200 OK - Request Successful:
+ value:
+ message: Profile image has been updated successfully.
+ meta: {}
+ responseCode: OK
+ result:
+ success: true
+ tags:
+ - Communications
+ /v1/communication/updateUser:
+ post:
+ summary: Update user
+ description: >-
+ This endpoint updates a user’s personal information, such as their name.
+ It enables the modification of a user's profile details to keep them
+ accurate and up-to-date in the communication system.
+ operationId: updateUser
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ name:
+ type: string
+ example: John
+ user_id:
+ type: string
+ example: 123e4567-e89b-12d3-a456-426614174000
+ required:
+ - name
+ - user_id
+ examples:
+ Update user:
+ value:
+ name: John
+ user_id: 123e4567-e89b-12d3-a456-426614174000
+ responses:
+ '200':
+ description: 200 OK - Request Successful
+ headers:
+ Access-Control-Allow-Origin:
+ schema:
+ type: string
+ example: '*'
+ Connection:
+ schema:
+ type: string
+ example: keep-alive
+ Content-Language:
+ schema:
+ type: string
+ example: en
+ Content-Length:
+ schema:
+ type: string
+ example: '113'
+ Date:
+ schema:
+ type: string
+ example: Wed, 04 Dec 2024 08:58:06 GMT
+ ETag:
+ schema:
+ type: string
+ example: W/"71-LgBVo91hr6UG/g93DebfNSoMkvs"
+ Keep-Alive:
+ schema:
+ type: string
+ example: timeout=5
+ X-Powered-By:
+ schema:
+ type: string
+ example: Express
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: User details has been successfully updated.
+ meta:
+ type: object
+ properties: {}
+ responseCode:
+ type: string
+ example: OK
+ result:
+ type: object
+ properties:
+ success:
+ type: boolean
+ example: true
+ examples:
+ 200 OK - Request Successful:
+ value:
+ message: User details has been successfully updated.
+ meta: {}
+ responseCode: OK
+ result:
+ success: true
+ tags:
+ - Communications
+components:
+ securitySchemes:
+ apiKey:
+ type: apiKey
+ name: internal_access_token
+ in: header
+security:
+ - apiKey: []
+tags:
+ - name: Communications
+ description: Base APIs
+ externalDocs:
+ description: ''
+ url: ''
diff --git a/src/envVariables.js b/src/envVariables.js
index e4ad44a..1d52bb2 100644
--- a/src/envVariables.js
+++ b/src/envVariables.js
@@ -5,7 +5,8 @@ let tableData = new table()
let environmentVariables = {
APPLICATION_ENV: {
message: 'Required node environment',
- optional: false,
+ optional: true,
+ default: 'production',
},
APPLICATION_PORT: {
@@ -33,7 +34,8 @@ let environmentVariables = {
CHAT_PLATFORM: {
message: 'Chat platform name',
- optional: false,
+ optional: true,
+ default: 'rocketchat',
},
CHAT_PLATFORM_URL: {
@@ -48,13 +50,17 @@ let environmentVariables = {
CHAT_PLATFORM_ADMIN_PASSWORD: {
message: 'Chat platform admin password',
- optional: false,
+ optional: true,
},
CHAT_PLATFORM_ADMIN_USER_ID: {
message: 'Chat platform admin user ID',
optional: false,
},
+ CHAT_PLATFORM_ACCESS_TOKEN: {
+ message: 'Chat platform admin token',
+ optional: false,
+ },
INTERNAL_ACCESS_TOKEN: {
message: 'Internal access token for secure communication',
diff --git a/src/generics/http-status.js b/src/generics/http-status.js
index 52b813a..844f62c 100644
--- a/src/generics/http-status.js
+++ b/src/generics/http-status.js
@@ -14,6 +14,7 @@ module.exports = {
forbidden: 403,
not_found: 404,
not_acceptable: 406,
+ conflict: 409,
unprocessable_entity: 422,
internal_server_error: 500,
}
diff --git a/src/locales/en.json b/src/locales/en.json
index 70a7355..08868e2 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -7,5 +7,6 @@
"USER_DOES_NOT_EXIST": "The specified user does not exist.",
"IMAGE_SET": "Profile image has been updated successfully.",
"CLIENT_ERROR": "An error occurred with the client request.",
- "NAME_UPDATED": "User details has been successfully updated."
+ "NAME_UPDATED": "User details has been successfully updated.",
+ "CHAT_ROOM_CREATED": "Chat room has been successfully updated."
}
diff --git a/src/middlewares/authenticator.js b/src/middlewares/authenticator.js
index 169f24c..8cdc49b 100644
--- a/src/middlewares/authenticator.js
+++ b/src/middlewares/authenticator.js
@@ -1,9 +1,3 @@
-/**
- * name : middlewares/authenticator
- * author : Aman Kumar Gupta
- * Date : 01-Oct-2021
- * Description : Validating authorized requests
- */
const httpStatusCode = require('@generics/http-status')
const apiResponses = require('@constants/api-responses')
const responses = require('@helpers/responses')
diff --git a/src/middlewares/validator.js b/src/middlewares/validator.js
index 1d8f456..93e8352 100644
--- a/src/middlewares/validator.js
+++ b/src/middlewares/validator.js
@@ -1,18 +1,37 @@
-/**
- * name : middlewares/validator
- * author : Aman Kumar Gupta
- * Date : 01-Oct-2021
- * Description : Contains logic to call required validator from validators directory to validate request data
- */
+const { validationResult } = require('express-validator');
+const path = require('path');
-const fs = require('fs')
+module.exports = async (req, res, next) => {
+ try {
+ const version = req.params.version;
+ const controllerName = req.params.controller;
+ const method = req.params.method;
-module.exports = (req, res, next) => {
- try {
- const version = (req.params.version.match(/^v\d+$/) || [])[0] // Match version like v1, v2, etc.
- const controllerName = (req.params.controller.match(/^[a-zA-Z0-9_-]+$/) || [])[0] // Allow only alphanumeric characters, underscore, and hyphen
- const method = (req.params.method.match(/^[a-zA-Z0-9]+$/) || [])[0] // Allow only alphanumeric characters
- require(`@validators/${version}/${controllerName}`)[method](req)
- } catch (error) {}
- next()
-}
+ // Dynamically load the validator for the given route
+ const validatorPath = path.resolve(__dirname, `../validators/${version}/${controllerName}.js`);
+ const validators = require(validatorPath);
+
+ // If the method has validators, execute them
+ if (validators[method]) {
+ await Promise.all(validators[method].map((validation) => validation.run(req)));
+ }
+
+ // Check for validation errors
+ const errors = validationResult(req);
+ if (!errors.isEmpty()) {
+ return res.status(422).json({
+ responseCode: 'VALIDATION_ERROR',
+ message: 'Validation failed. Check input data.',
+ errors: errors.array(),
+ });
+ }
+
+ next();
+ } catch (error) {
+ // If no validator exists, continue without validation
+ if (error.code === 'MODULE_NOT_FOUND') {
+ return next();
+ }
+ next(error);
+ }
+};
diff --git a/src/routes/index.js b/src/routes/index.js
index efae4e9..41c33ac 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -1,14 +1,10 @@
const validator = require('@middlewares/validator')
const authenticator = require('@middlewares/authenticator')
-//const pagination = require('@middlewares/pagination')
-const expressValidator = require('express-validator')
const fs = require('fs')
const path = require('path')
module.exports = (app) => {
app.use(authenticator)
- //app.use(pagination)
- //app.use(expressValidator())
async function getAllowedControllers(directoryPath) {
try {
const getAllFilesAndDirectories = (dir) => {
@@ -57,7 +53,6 @@ module.exports = (app) => {
}
async function router(req, res, next) {
let controllerResponse
- let validationError
const version = (req.params.version.match(/^v\d+$/) || [])[0] // Match version like v1, v2, etc.
const controllerName = (req.params.controller.match(/^[a-zA-Z0-9_-]+$/) || [])[0] // Allow only alphanumeric characters, underscore, and hyphen
@@ -91,23 +86,6 @@ module.exports = (app) => {
return next(error)
}
- /* Check for input validation error */
- /* try {
- validationError = req.validationErrors()
- } catch (error) {
- error.statusCode = 422
- error.responseCode = 'CLIENT_ERROR'
- return next(error)
- }
-
- if (validationError.length) {
- const error = new Error('Validation failed, Entered data is incorrect!')
- error.statusCode = 422
- error.responseCode = 'CLIENT_ERROR'
- error.data = validationError
- return next(error)
- } */
-
try {
let controller
if (req.params.file) {
diff --git a/src/services/communication.js b/src/services/communication.js
index 0b0bbe5..a44946c 100644
--- a/src/services/communication.js
+++ b/src/services/communication.js
@@ -40,10 +40,9 @@ module.exports = class CommunicationHelper {
static async signup(bodyData) {
const userExists = await userQueries.findOne({ user_id: bodyData.user_id })
if (userExists) {
- return responses.successResponse({
- statusCode: httpStatusCode.created,
+ return responses.failureResponse({
+ statusCode: httpStatusCode.conflict,
message: 'USER_ALREADY_EXISTS',
- result: userExists,
})
}
let chatResponse = await chatAPIs.signup(
@@ -112,6 +111,13 @@ module.exports = class CommunicationHelper {
if (bodyData.token) {
chatResponse = await chatAPIs.logout(bodyData.user_id, bodyData.token)
} else {
+ const userExists = await userQueries.findOne({ user_id: bodyData.user_id })
+ if (!userExists) {
+ return responses.failureResponse({
+ statusCode: httpStatusCode.not_found,
+ message: 'USER_DOES_NOT_EXIST',
+ })
+ }
const loginResponse = await chatAPIs.login(
usernameHash(bodyData.user_id),
passwordHash(bodyData.user_id)
@@ -162,7 +168,7 @@ module.exports = class CommunicationHelper {
)
return responses.successResponse({
statusCode: httpStatusCode.ok,
- message: 'LOGGED_IN',
+ message: 'CHAT_ROOM_CREATED',
result: chatResponse,
})
} catch (error) {
diff --git a/src/validators/v1/communication.js b/src/validators/v1/communication.js
index e69de29..4bf1963 100644
--- a/src/validators/v1/communication.js
+++ b/src/validators/v1/communication.js
@@ -0,0 +1,61 @@
+const { check, body } = require('express-validator')
+
+module.exports = {
+ signup: [
+ check('user_id')
+ .notEmpty()
+ .withMessage('User ID is required.')
+ .isString()
+ .withMessage('User ID must be a string.'),
+ check('name').notEmpty().withMessage('Name is required.').isString().withMessage('Name must be a string.'),
+ check('email').notEmpty().withMessage('Email is required.').isEmail().withMessage('Invalid email format.'),
+ check('image_url').optional().isURL().withMessage('Image URL must be a valid URL.'),
+ ],
+ login: [
+ check('user_id')
+ .notEmpty()
+ .withMessage('User ID is required.')
+ .isString()
+ .withMessage('User ID must be a string.'),
+ ],
+ logout: [
+ check('user_id')
+ .notEmpty()
+ .withMessage('User ID is required.')
+ .isString()
+ .withMessage('User ID must be a string.'),
+ check('token').optional().isString().withMessage('Token must be a string if provided.'),
+ ],
+ createRoom: [
+ body('usernames')
+ .isArray({ min: 2, max: 2 })
+ .withMessage('Usernames must be an array of two usernames.')
+ .custom((usernames) => usernames.every((username) => typeof username === 'string'))
+ .withMessage('Each username must be a string.'),
+ check('initial_message')
+ .notEmpty()
+ .withMessage('Initial message is required.')
+ .isString()
+ .withMessage('Initial message must be a string.'),
+ ],
+ updateAvatar: [
+ check('user_id')
+ .notEmpty()
+ .withMessage('User ID is required.')
+ .isString()
+ .withMessage('User ID must be a string.'),
+ check('image_url')
+ .notEmpty()
+ .withMessage('Image URL is required.')
+ .isURL()
+ .withMessage('Image URL must be a valid URL.'),
+ ],
+ updateUser: [
+ check('user_id')
+ .notEmpty()
+ .withMessage('User ID is required.')
+ .isString()
+ .withMessage('User ID must be a string.'),
+ check('name').notEmpty().withMessage('Name is required.').isString().withMessage('Name must be a string.'),
+ ],
+}