{"id":20601676,"url":"https://github.com/rolling-scopes-school/fun-chat-server","last_synced_at":"2025-04-15T01:50:50.181Z","repository":{"id":222843870,"uuid":"746307876","full_name":"rolling-scopes-school/fun-chat-server","owner":"rolling-scopes-school","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-13T19:46:32.000Z","size":109,"stargazers_count":6,"open_issues_count":0,"forks_count":80,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T20:36:10.874Z","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/rolling-scopes-school.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}},"created_at":"2024-01-21T17:23:28.000Z","updated_at":"2025-04-13T19:46:36.000Z","dependencies_parsed_at":"2024-04-19T16:01:58.772Z","dependency_job_id":null,"html_url":"https://github.com/rolling-scopes-school/fun-chat-server","commit_stats":null,"previous_names":["rolling-scopes-school/fun-chat-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolling-scopes-school%2Ffun-chat-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolling-scopes-school%2Ffun-chat-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolling-scopes-school%2Ffun-chat-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolling-scopes-school%2Ffun-chat-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rolling-scopes-school","download_url":"https://codeload.github.com/rolling-scopes-school/fun-chat-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991539,"owners_count":21194894,"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-16T09:11:38.851Z","updated_at":"2025-04-15T01:50:50.172Z","avatar_url":"https://github.com/rolling-scopes-school.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Server Application for the Chat. API\n\n### Install and Run the Application\n\nTo use the chat server application follow these steps:\n\n- clone the repository\n- install the dependencies with `npm i`\n- create the `.env` file and specify the [port settings](#Setting-the-Listening-Port-Parameters) and server [event log settings](#Server-Event-Display-Settings) in it\n- start the local server using `npm run start`\n\nThe server runs on port 4000 and listens for messages from client applications.\n\nIn the `.env.example` file, you can find an example of basic parameter settings for the `.env` file.\n\nTo apply the modified parameters, you will need to restart the server.\n\n### Setting the Listening Port Parameters\n\nIn the created `.env` file, set the `SERVER_PORT` parameter to `4000`.\n\nIf it is not possible to run the server using port `4000`, you can use another port.\n\n### Server Event Display Settings\n\nThe server event log facilitates real-time tracking of incoming requests received by the server and responses sent by the server.\n\nIn the created `.env` file, set the `LOG`  parameter to one of the values listed in this section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Log Display Options\u003c/summary\u003e\n\n- `ALL` - all incoming and outgoing requests\n- `ERROR` - only erroneous requests\n- `INCOMING` - all incoming requests\n- `OUTCOMING` - all outgoing requests\n- `NONE` - request logging disabled\n\n\u003c/details\u003e\n\n### General Information\n\nThe server application utilizes the [WebSocket protocol](https://websockets.spec.whatwg.org/) where the initiator of the request can be either a client or server application. To use the protocol you will need to familiarize yourself with the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket).\n\nUpon a request to the server, the client will receive a response containing information about the processing result of the request. Some client requests may trigger the server to send additional requests to other clients - such situations are specified in the request description.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eGeneral request format\u003c/summary\u003e\n\n```javascript\n{\n  id: string | null\n  type: string,\n  payload: {\n    // Request payload\n  },\n}\n```\n\nwhere:\n\n- `id` - request identifier, generated by the client application, the value will be returned by the server in the `id` field in the response. If a server application is the initiator, the id value of request identifier will be null.\n- `type` - request name\n- `payload` - request payload\n\u003c/details\u003e\n\n### User Authentication\n\nInitiator: Client application\n\nDescription: Used to authenticate the current user or create a new user. Upon successful completion, the server sends a request to all authenticated users according to the [\"Third-party User Authentication\"](#Third-party-User-Authentication) section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_LOGIN\",\n  payload: {\n    user: {\n      login: string,\n      password: string,\n    },\n  },\n}\n```\n\nwhere:\n\n- `id` - request identifier\n- `login` - user's login\n- `password` - user's password\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_LOGIN\",\n  payload: {\n    user: {\n      login: string,\n      isLogined: boolean,\n    },\n  },\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `login` - user's login\n- `isLogined` - current authentication status of the user\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Responses for Errors\u003c/summary\u003e\n\n- user with the specified login is already logged in\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"a user with this login is already authorized\",\n    }\n  }\n  ```\n\n- another user is already authorized in this connection \n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"another user is already authorized in this connection\",\n    }\n  }\n  ```\n\n- the provided password does not match the provided login\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"incorrect password\",\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the cause of the error\n\u003c/details\u003e\n\n### User Logout\n\nInitiator: Client application\n\nDescription: Used to end the session for the current user. Upon successful completion, the server sends a request to all authorized users in accordance with the [\"Third-Party User Logout\"](#Third-Party-User-Logout) section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_LOGOUT\",\n  payload: {\n    user: {\n      login: string,\n      password: string,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier\n- `login` - user's login\n- `password` - user's password\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_LOGOUT\",\n  payload: {\n    user {\n      login: string,\n      isLogined: boolean,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `login` - user's login\n- `isLogined` - current authentication status of the user\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Responses in Case of Errors\u003c/summary\u003e\n\n- the user with the specified login does not exist\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"there is no user with this login\",\n    }\n  }\n  ```\n\n- the provided password and login do not match\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"incorrect password\",\n    }\n  }\n  ```\n\n- the user with the specified login is not authorized\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"the user was not authorized\",\n    }\n  }\n  ```\n\n- the user with the specified login is already authorized in another client connection\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"a user with this login is already authorized\",\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the cause of the error\n\u003c/details\u003e\n\n### Third-party User Authentication\n\nInitiator: Server application\n\nDescription: Is sent by the server to all authorized users after receiving a request in accordance with [\"User Authentication\"](#User-Authentication) section, indicating a successful result of the authorization of the user.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest from the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: null,\n  type: \"USER_EXTERNAL_LOGIN\",\n  payload: {\n    user: {\n      login: string,\n      isLogined: boolean,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier generated by the server\n- `login` - username of the user who logged in\n- `isLogined` - current authentication status of the user\n\u003c/details\u003e\n\n### Third-Party User Logout\n\nInitiator: Server application\n\nDescription: Is sent by the server to all authenticated users:\n- after receiving a request according to the [\"User Logout\"](#User-Logout) section as a result of processing which the user's session is terminated.\n- when the connection with an authorized user is broken by the client application, as a result of which the server changes the user's authorization state `isLogined` to `false`.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest from the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: null,\n  type: \"USER_EXTERNAL_LOGOUT\",\n  payload: {\n    user: {\n      login: string,\n      isLogined: boolean,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier generated by the server\n- `login` - username of the user who logged out of the application\n- `isLogined` - current authentication status of the user\n\u003c/details\u003e\n\n### Getting All Authenticated Users\n\nInitiator: Client application\n\nDescription: Used to retrieve a list of all authenticated users.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_ACTIVE\",\n  payload: null,\n}\n```\n\nwhere:\n\n- `id` - request identifier\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_ACTIVE\",\n  payload: {\n    users: [],\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `users` - array of authenticated users structurally corresponding to the `user` field in [\"Third-party User Authentication\"](#Third-party-User-Authentication) section. An empty array is not considered an error.\n\u003c/details\u003e\n\n### Getting All Unauthorized Users\n\nInitiator: Client application\n\nDescription: Used to retrieve a list of all unauthorized users.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_INACTIVE\",\n  payload: null,\n}\n```\n\nwhere:\n\n- `id` - request identifier\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"USER_INACTIVE\",\n  payload: {\n    users: [],\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `users` - array of unauthorized users structurally corresponding to the `user` field in [\"Third-party User Authentication\"](#Third-party-User-Authentication) section. An empty array is not considered an error.\n\u003c/details\u003e\n\n### Sending a Message to a User\n\nInitiator: Client application\n\nDescription: Used to send a message to another user. If the message recipient is authenticated, the message is immediately directed to them according to the [\"Receiving a Message From a User\"](#Receiving-a-Message-From-a-User) section and the `isDelivered` status of the message is set to `true`. If the recipient is not authenticated, the message will be received along with all messages when requested according to the [\"Fetching Message History With the User\"](#Fetching-Message-History-With-the-User) section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_SEND\",\n  payload: {\n    message: {\n      to: string,\n      text: string,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier\n- `to` - login of the user to whom the message is being sent\n- `text` - text of the message\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_SEND\",\n  payload: {\n    message: {\n      id: string,\n      from: string,\n      to: string,\n      text: string,\n      datetime: number,\n      status: {\n        isDelivered: boolean,\n        isReaded: boolean,\n        isEdited: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `message` - created message where:\n  - `id` - message identifier, generated by the server\n  - `from` - sender of the message\n  - `to` - recipient of the message\n  - `text` - text of the message\n  - `datetime` - date and time when the message was sent\n  - `isDelivered` - status which indicates whether the message has been delivered to the recipient\n  - `isReaded` - status which indicates whether the message has been read by the recipient\n  - `isEdited` - status which indicates whether the message has been edited by the sender\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Responses in Case of Errors\u003c/summary\u003e\n\n- the sender's and recipient's logins match\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: 'sender and recipient logins are the same',\n    }\n  }\n  ```\n\n- the user with the specified login does not exist\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: 'the user with the specified login does not exist',\n    }\n  }\n  ```\n\n- the user sending the request is not authenticated\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: 'user not registered or not logged',\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the cause of the error\n\u003c/details\u003e\n\n### Receiving a Message From a User\n\nInitiator: Server application\n\nDescription: Is sent by the server to the user specified as the recipient when requested in accordance with [\"Sending a Message to a User\"](#Sending-a-Message-to-a-User) section. The message is sent if the recipient user is authenticated.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest from the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: null,\n  type: \"MSG_SEND\",\n  payload: {\n    message: {\n      id: string,\n      from: string,\n      to: string,\n      text: string,\n      datetime: number,\n      status: {\n        isDelivered: boolean,\n        isReaded: boolean,\n        isEdited: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier generated by the server\n- `message` - user's message field where:\n  - `id` - message identifier\n  - `from` - sender of the message\n  - `to` - recipient of the message\n  - `text` - text of the message\n  - `datetime` - date and time when the message was sent\n  - `isDelivered` - status which indicates whether the message has been delivered to the recipient\n  - `isReaded` - status which indicates whether the message has been read by the recipient\n  - `isEdited` - status which indicates whether the message has been edited by the sender\n  \u003c/details\u003e\n\n### Fetching Message History With the User\n\nInitiator: Client application\n\nDescription: Used to retrieve a list of all messages with a specific user. All messages with the `isDelivered` status set to `false` will update the status to `true` if the request is made by the recipient user. In this case, for each message, the server will make a request to the sender user according to the [\"Notification of Message Delivery Status Change\"](#Notification-of-Message-Delivery-Status-Change) section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_FROM_USER\",\n  payload: {\n    user: {\n      login: string,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier\n- `login` - username of the user with whom the message history is requested\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_FROM_USER\",\n  payload: {\n    messages: [],\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `messages` - array of messages sorted in ascending order by date and time, structurally corresponding to the `message` field in [\"Receiving a Message From a User\"](#Receiving-a-Message-From-a-User) section. An empty array is not considered an error.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Responses in Case of Errors\u003c/summary\u003e\n\n- the sender's and recipient's logins match\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: 'sender and recipient logins are the same',\n    }\n  }\n  ```\n\n- the user with the specified login does not exist\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: 'the user with the specified login does not exist',\n    }\n  }\n  ```\n\n- the user sending the request is not authenticated\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: 'user not registered or not logged',\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the cause of the error\n\u003c/details\u003e\n\n### Notification of Message Delivery Status Change\n\nInitiator: Server application\n\nDescription: The request is sent to the message sender when the server receives a request from the recipient user according to the [\"Fetching Message History With the User\"](#Fetching-Message-History-With-the-User) section and the current status `isDelivered` is `false`. In this case, the server sets the `isDelivered` status to `true` before forwarding the message to the sender user.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest from the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: null,\n  type: \"MSG_DELIVER\",\n  payload: {\n    message: {\n      id: string,\n      status: {\n        isDelivered: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier generated by the server\n- `message` - user's message field where:\n  - `id` - message identifier\n  - `isDelivered` - status which indicates whether the message has been delivered to the recipient\n  \u003c/details\u003e\n\n### Message Read Status Change\n\nInitiator: Client application\n\nDescription: Used to change the status of `isReaded` to `true`. Upon successful processing of the request, the server sends a notification to the sender in accordance with [\"Notification of Message Read Status Change\"](#Notification-of-Message-Read-Status-Change) section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_READ\",\n  payload: {\n    message: {\n      id: string,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier\n- `message` - user's message field where:\n  - `id` - message identifier\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_READ\"\n  payload: {\n    message: {\n      id: string,\n      status: {\n        isReaded: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `message` - user's message field where:\n  - `id` - message identifier\n  - `isReaded` - current read status of the message\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Responses in Case of Errors\u003c/summary\u003e\n\n- the message with the provided `id` does not exist\n\n```javascript\n{\n  id: string,\n  type: \"ERROR\"\n  payload: {\n    error: 'incorrect message id',\n  }\n}\n```\n\n- the user sending the request is not the recipient of the message\n\n```javascript\n{\n  id: string,\n  type: \"ERROR\"\n  payload: {\n    error: 'user not recipient cannot be executed',\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `error` - description of the cause of the error\n\u003c/details\u003e\n\n### Notification of Message Read Status Change\n\nInitiator: Server application\n\nDescription: This request is sent to the user who sent the message after the server successfully processes the request to change the `isReaded` status according to [\"Message Read Status Change\"](#Message-Read-Status-Change) section, provided that the sending user is authenticated.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest from the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: null,\n  type: \"MSG_READ\"\n  payload: {\n    message: {\n      id: string,\n      status: {\n        isReaded: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier generated by the server\n- `message` - user's message field where:\n  - `id` - message identifier\n  - `isReaded` - current read status of the message\n  \u003c/details\u003e\n\n### Message Deletion\n\nInitiator: Client application\n\nDescription: Used to delete a message sent to another user. If the recipient is authenticated, a notification is sent to them according to [\"Notification of Message Deletion\"](#Notification-of-Message-Deletion) section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_DELETE\"\n  payload: {\n    message: {\n      id: string,\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier\n- `message` - user's message field where:\n  - `id` - message identifier\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_DELETE\"\n  payload: {\n    message: {\n      id: string,\n      status: {\n        isDeleted: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `message` - created message where:\n  - `id` - message identifier\n  - `isDeleted` - status which indicates whether the message has been deleted\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Responses in Case of Errors\u003c/summary\u003e\n\n- the message with the provided `id` does not exist\n\n```javascript\n{\n  id: string,\n  type: \"ERROR\"\n  payload: {\n    error: 'incorrect message id',\n  }\n}\n```\n\n- the user is not the sender of the message\n\n```javascript\n{\n  id: string,\n  type: \"ERROR\"\n  payload: {\n    error: 'user not sender cannot be executed',\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `error` - description of the cause of the error\n\u003c/details\u003e\n\n### Notification of Message Deletion\n\nInitiator: Server application\n\nDescription: This request is sent to the recipient user after the server successfully processes a message deletion request in accordance with [\"Message Deletion\"](#Message-Deletion) section, provided that the recipient user is authorized.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest from the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: null,\n  type: \"MSG_DELETE\"\n  payload: {\n    message: {\n      id: string,\n      status: {\n        isDeleted: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier generated by the server\n- `message` - created message where:\n  - `id` - message identifier\n  - `isDeleted` - status which indicates whether the message has been deleted\n  \u003c/details\u003e\n\n### Message Text Editing\n\nInitiator: Client application\n\nDescription: Used to edit the text of a message sent to another user. If the recipient of the message is authorized, a notification is sent to them in accordance with [\"Notification of Message Text Editing\"](#Notification-of-Message-Text-Editing) section.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest to the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_EDIT\"\n  payload: {\n    message: {\n      id: string,\n      text: string\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier\n- `message` - user's message field where:\n  - `id` - message identifier\n  - `text` - text of the message\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Response\u003c/summary\u003e\n\n```javascript\n{\n  id: string,\n  type: \"MSG_EDIT\"\n  payload: {\n    message: {\n      id: string,\n      text: string,\n      status: {\n        isEdited: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `message` - created message where:\n  - `id` - message identifier\n  - `text` - edited text of the message\n  - `isEdited` - status which indicates whether the message has been edited\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eServer Responses in Case of Errors\u003c/summary\u003e\n\n- the message with the provided `id` does not exist\n\n```javascript\n{\n  id: string,\n  type: \"ERROR\"\n  payload: {\n    error: 'incorrect message id',\n  }\n}\n```\n\n- another user is the sender of the message\n\n```javascript\n{\n  id: string,\n  type: \"ERROR\"\n  payload: {\n    error: 'user not sender cannot be executed',\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier received from the client\n- `error` - description of the cause of the error\n\u003c/details\u003e\n\n### Notification of Message Text Editing\n\nInitiator: Server application\n\nDescription: This request is sent to the recipient user after the server successfully processes a message editing request in accordance with [\"Message Text Editing\"](#Message-Text-Editing) section, provided that the recipient user is authorized.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest from the Server\u003c/summary\u003e\n\n```javascript\n{\n  id: null,\n  type: \"MSG_EDIT\"\n  payload: {\n    message: {\n      id: string,\n      text: string,\n      status: {\n        isEdited: boolean,\n      }\n    }\n  }\n}\n```\n\nwhere:\n\n- `id` - request identifier generated by the server\n- `message` - created message where:\n  - `id` - message identifier\n  - `text` - edited text of the message\n  - `isEdited` - status which indicates whether the message has been edited\n  \u003c/details\u003e\n\n### Server Responses in Case of Request Errors\n\nWhen an error occurs in the request, the server returns a message indicating the reason for the error.\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eGeneral Response Format for Requests with Errors\u003c/summary\u003e\n\n- detailed descriptions of errors and their causes are provided in the request descriptions\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: string,\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the error\n\u003c/details\u003e\n\nServer Responses for Common Errors\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eIncorrect Request Structure\u003c/summary\u003e\n\n- sent by the server in response to a request that does not contain one of the mandatory fields (`id`, `type`, `payload`) or if the field type does not match this description\n\n  ```javascript\n  {\n    id: string | null,\n    type: \"ERROR\",\n    payload: {\n      error: \"incorrect request structure\",\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client or `null` if there is no identifier in the request\n- `error` - description of the error\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest Type \u003c/summary\u003e\n\n- sent by the server in response to a request with a `type` parameter not supported by the server\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"incorrect type parameters\",\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the error\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eRequest Payload Is Not Supported by the Server\u003c/summary\u003e\n\n- sent by the server in response to a request with a `payload` parameter not supported by the server\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"incorrect payload parameters\",\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the error\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary markdown=\"span\"\u003eInternal Server Error\u003c/summary\u003e\n\n- sent by the server in response to a request that resulted in an unexpected error\n\n  ```javascript\n  {\n    id: string,\n    type: \"ERROR\",\n    payload: {\n      error: \"internal server error\",\n    }\n  }\n  ```\n\n  where:\n\n- `id` - request identifier received from the client\n- `error` - description of the error\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolling-scopes-school%2Ffun-chat-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frolling-scopes-school%2Ffun-chat-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolling-scopes-school%2Ffun-chat-server/lists"}