# API Maker Configuration

> Every setting of an API Maker server - ports, databases and Redis of API Maker itself, JWT and token validity, sandbox, logs, limits - in the am section of package.json, overridable from a .env file with the am__ prefix.

Source: https://docs.apimaker.dev/v1/docs/am-resources/api-maker-configurations.html

The server reads its settings from the `am` section of its `package.json`, and a `.env` file overrides any of them.

| | |
|---|---|
| Override | `am__<key>` in `.env` : `am__port=38246`. A nested key joins with `__` : `am__jwtOptions__issuer=AM_JWT`. |
| Where is `.env` | Next to the install, or `node main.js --envPath=/root/config/.env`. The [installer](https://docs.apimaker.dev/v1/docs/getting-started/install-on-server.html) writes the file for you. |
| See them | `Dashboard → Server Node Configurations` shows the values every server runs with. |

## The keys

- serverName : It will be seen in nodes summary dashboard, so you can easily identify different servers.

    ```json
    "Default" : "server1"
    ```

- processTitle : This will be title of API Maker process when it starts.

    ```json
    "Default" : "api_maker_be"
    ```

- cpuCount

    1 = default. One API Maker process will be created.
    AUTO = If you give this value, it will create N number of processes where N = CPU core.
    2 = It will create 2 API Maker processes.

    ```json
    "Default" : "1"
    ```

- port : API Maker will start on this port.

    ```json
    "Default" : "38246"
    ```

- wsPort : API Maker will start WebSocket connection on this port. So frontend or mobile app can connect to this port for WebSocket notifications.

    ```json
     "Default" : "38245"
    ```

- mongo_db_connection : Database connection string of API Maker`s internal use.

**logs**

- enableLogs : If true, logging is enable.

    ```json
    "Default" : "true"
    ```

- mongo_db_connection_logs : Logging database connection string. API Maker will store user's logs in this database.

- logRemoveSchedulerInterval

    API Maker will start log removal scheduler based on this value.
    Default is every day.

    ```json
    "Default" : "0 0 0 * * *"
    ```

- maxLogsCount

    Maximum amount of logs to keep in log database.
    API Maker will run scheduler based on `logRemoveSchedulerInterval` and remove older logs.

    ```json
    "Default" : "100000"
    ```

**redisInternal**

Used by API Maker for it's internal use. It stores user's auto increment values in this redis. Clustering supported.

- nodes : List of redis nodes.

- port : Internal redis port.

    ```json
    "Default" : "6379"
    ```

- host : Internal redis host.

    ```json
    "Default" : "127.0.0.1"
    ```

- pass : Internal redis password.

- maxCharsToStoreInConsoleLogs

    Console logs in custom code will allow these many characters to be stored for each admin & developer user, it will be cleared after that.
    AM version required >= 1.15.0

**redisExternal**

Used to give caching support for user's APIs. Clustering supported.

- nodes : List of redis nodes.

- port : External redis port.

    ```json
    "Default" : "6390"
    ```

- host : External redis host.

    ```json
    "Default" : "127.0.0.1"
    ```

- pass : External redis password.

- otherRedisClusterOptions : Other redis cluster related options supported by ioredis NPM Package.

- redisValueExpireInSeconds

    Every key set by user in redis will expire automatically after this many seconds.
    It will keep redis clean.
    Ex : If you set value 29 over here, it means every key in redis expires after 29 seconds or TTL given by user while setting the key.

    ```json
    "Default" : "7200"
    ```

- maxCharsResToCache

    1000000 = If value has more than 1000000 characters, it will not be stored in redis.
    We should not store huge strings in redis.

    ```json
    "Default" : "1000000"
    ```

**jwtOptions [For API Maker users sessions only]**

- expiresIn : We can specify Token expire time limit from here, it should be always number in seconds.

    ```json
    "Default" : "259200"    // 72 hours
    ```

    For your application's JWT token settings, Please log in into root user settings.

- issuer : Specify the API Maker issuer of JWT generator.

    ```json
    "Default" : "API Maker JWT Generator"
    ```

**sandbox**

- imageName: { sandboxNode : }

    ```json
    "Default": "am/sandbox-node, nodejs sandbox image name"
    ```

- sandboxReqTimeout : Defines the maximum milliSecond allowed to complete the execution process.

    ```json
    "Default" : "13000"
    ```

- sandboxCountForAdmin : Process will create these many sandbox environment containers to handle multiple requests.

    ```json
    "Default" : "2"
    ```

- sandboxMaxOldSpaceMB

    Default is 2500 or (total_memory / cpu_count) MB whichever is max.
    AM version required >= 1.10.0

- removeSandboxInactiveSinceMinutes : Remove sandbox of admins which is not used since this minutes to free resources. For that scheduler will run every (removeSandboxInactiveCron = 10) minutes to check these minutes.

    ```json
    "Default" : "5"
    ```

    (Note : We can give like 0.25 float value also)

**defaultCreation**

- apiUserPass : Here, we can set password for the default API User.

    ```json
    "Default" : "12345"
    ```

- passCommunication

    Used for communication between API Maker frontend and API Maker backend.
    It is not used for user data transmission.
    It's value should be same in all servers of environment(dev|qa|uat|prod) of project.

- passJWT

    Used for generating jwt token.
    It's value should be same for all environments of that project in all server deployment.

- passDBEncryptDecrypt

    Values in API Maker mongoDB database and passwords in git repository, will be encrypted using this password.
    It's value should be same for all environments of that project in all server deployment.
    If value is not same, API Maker will not able to decrypt git repository values.

- feTransferDataValidityInSecondsDefault : Encrypted data sent by frontend or mobile apps, will be expired after this many seconds.

    ```json
    "Default" : "15"
    ```

- refreshTokenValidForS : Refresh token will be valid after these many seconds of expiring access token.

    ```json
    "Default" : "900"
    ```

- importDefaultUsers : API Maker will insert default users from this JSON file when these emails are not present in API Maker's MongoDB.

    ```json
    "Default" : "src/json/DefaultUsers.json"
    ```

- compressThreshold : If response is greater than 51200 characters then it will be compressed otherwise not.

    ```json
    "Defaults" : "51200" 
    ```

- bodyLimit : Defines the maximum payload in bytes, the server is allowed to accept.

    ```json
    "Default" : "10484711424" (9999MiB) 
    Google: Byte -> Mebibyte(MiB)
    ```

- cron_job_time_zone : API Maker's internal schedulers will run on this time zone.

    ```json
    "Default" : "Asia/Kolkata"
    ```

- store_url : API Maker will install APIs from store from below URL.

    ```json
    "Default" : "https://store.be.apimaker.dev"
    ```

- maximum_test_user_count : Fetch maximum these many test usernames from table if count is not provided in schema

    ```json
    "Default" : "1000"
    ```

- uploadedFileCleaningSchedulerCron

    Scheduler will run every this much time and clean files which are older than uploadedFileRemoveOlderThanThisTimeInSeconds.
    Default : 30 minutes

    ```json
    "Default" : "0 */30 * * * *"
    ```

- uploadedFileRemoveOlderThanThisTimeInSeconds

    Remove uploaded files older than time specified in second at this field.
    Default : 1800 seconds (30 Minutes)

    ```json
    "Default" : "1800"
    ```

|  |  |
|---|---|
| **other keys** |  |
| BE_HOST_PORT, BE_WS_HOST_PORT | The public URL of the API and of the WebSocket server, used in the URLs API Maker prints and in the links of the admin panel. The installer sets them. |
| envPath, logFilePath, oracleClientPath | Where the .env file is, where the process log is written, where the Oracle Instant Client is installed. |
| docker | How to reach the Docker daemon which runs the sandboxes : `socketPath`, or `protocol`, `host` and `port`. |
| debugging.portStart, debugging.portEnd | The ports the [debugger](https://docs.apimaker.dev/v1/docs/features/developer-tools.html#debugger) of the sandboxes may use. |
| db.common.cleanPoolInMinutes | Idle database connection pools are closed after this many minutes. |
| db.mongo.max_rows_return | The number of rows a get all or a query returns when the request gives no `limit`. |

## Related

- [Install API Maker](https://docs.apimaker.dev/v1/docs/getting-started/install-on-server.html) · [Node dashboard](https://docs.apimaker.dev/v1/docs/dashboard/node-dashboard.html) · [Deploy API Maker](https://docs.apimaker.dev/v1/docs/features/deploy-api-maker.html)
