# Config files

In the root `messenger-app` directory and also in directories `messenger-api/src` and  `socket-server/src` is a config file. It is divided into three groups: development, staging, and production.

## Socket Server

{% code title="socket-server/src/config.js" %}

```javascript
{
  development: {
    port: 4000, // node server port 
    socket_secret: 'SOCKET SECRET',
    redis: {
      host: 'localhost',
      port: 6379
    }
  },
  production: {
    port: 4000, // node server port 
    socket_secret: 'SOCKET SECRET',
    redis: {
      host: '<redis-host>',
      port: 6379,
      pass: '<redis-password>' // Optional, if the password for redis exists
    }
  },
  staging: {
    port: 4000, // node server port 
    socket_secret: 'SOCKET SECRET',
    redis: {
      host: '<redis-host>',
      port: 6379,
      pass: '<redis-password>' // Optional, if the password for redis exists
    }
  }
}
```

{% endcode %}

{% hint style="info" %}
For users authorization on Socket Server, uses`socket_secret` key, which should be the same in the config files on Socket Server and API Server&#x20;
{% endhint %}

## API Server

{% code title="messenger-api/src/config.js" %}

```javascript
{
  development: {
    port: 3000, // node server port 
    mongoURI: 'mongodb://localhost:27017/messenger',
    socket_secret: 'SOCKET SECRET',
    redis: {
      host: 'localhost',
      port: 6379
    }
  },
  production: {
    port: 3000, // node server port 
    mongoURI: 'mongodb://<mongo-host>:27017/messenger',
    socket_secret: 'SOCKET SECRET',
    redis: {
      host: '<redis-host>',
      port: 6379,
      password: '<redis-password>' // Optional, if the password for redis exists
    }
  },
  staging: {
    port: 3000, // node server port 
    mongoURI: 'mongodb://<mongo-host>:27017/messenger',
    socket_secret: 'SOCKET SECRET',
    redis: {
      host: '<redis-host>',
      port: 6379,
      password: '<redis-password>' // Optional, if the password for redis exists
    }
  }
```

{% endcode %}

{% hint style="info" %}
For users authorization on Socket Server, uses`socket_secret` key, which should be the same in the config files on Socket Server and API Server&#x20;
{% endhint %}

## Messenger App

{% code title="messenger-app/config.js" %}

```javascript
const awsConfig = {
  bucket: '<your-bucket>',
  accessKey: '<access-key>',
  secretKey: '<secret-key>',
  region: '<region>'
};

const development = {
  apiHost: 'http://localhost:3000',
  socketHost: 'http://localhost:4000',
  awsConfig
};

const production = {
  apiHost: 'http(s)://<api-host>:<PORT>',
  socketHost: 'http(s)://<socket-host>:<PORT>',
  awsConfig
};

```

{% endcode %}

[How to get AWS access key and secret key ](https://aws.amazon.com/ru/blogs/security/how-to-find-update-access-keys-password-mfa-aws-management-console/)

## Note

**About socket secret**

`socket_secret` is needed to calculate the authorization token on Socket Server.  &#x20;

`(user_token === md5(user_id + socket_secret))`

`user_token` is generated on API Server during authorization and transmitted when application establishes a connection with Socket Server


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://luice96.gitbook.io/messenger/config-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
