Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 3e2bf4d

Browse files
committed
v1.2.7
1 parent 7d48dbb commit 3e2bf4d

7 files changed

Lines changed: 23 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules
33
package-lock.json
44
licenses.csv
5+
.env

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ Once application is started open http://127.0.0.1:3000/ for instructions and API
9191

9292
![](https://cldup.com/mK0aS_uVfQ.png)
9393

94+
## Config mapping
95+
96+
| Configuration option | CLI argument | ENV value | Default |
97+
| -------------------- | ---------------------- | -------------------- | ---------------------------- |
98+
| Redis connection URL | `--dbs.redis="url"` | `REDIS_URL="url"` | `"redis://127.0.0.1:6379/8"` |
99+
| Host to bind to | `--api.host="1.2.3.4"` | `API_HOST="1.2.3.4"` | `"127.0.0.1"` |
100+
| Port to bind to | `--api.port=port` | `API_HOST=port` | `3000` |
101+
| Log level | `--log.level="level"` | `LOG_LEVEL=level` | `"trace"` |
102+
103+
> **NB!** environment variables override CLI arguments. CLI arguments override configuration file values.
104+
105+
If available then IMAP API uses dotenv file from project root to populate environment variables.
106+
94107
## Example
95108

96109
#### 1. Set up webhook target

lib/db.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ const fs = require('fs');
44
const config = require('wild-config');
55
const Queue = require('bull');
66
const Redis = require('ioredis');
7-
const redis = new Redis(config.dbs.redis);
7+
const redis = new Redis(process.env.REDIS_URL || config.dbs.redis);
88

9-
const notifyQueue = new Queue('notify', { redis: config.dbs.redis });
9+
const notifyQueue = new Queue('notify', { redis: process.env.REDIS_URL || config.dbs.redis });
1010

1111
const zExpungeScript = fs.readFileSync(__dirname + '/lua/z-expunge.lua', 'utf-8');
1212
const zSetScript = fs.readFileSync(__dirname + '/lua/z-set.lua', 'utf-8');

lib/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const config = require('wild-config');
44
const pino = require('pino');
55

66
let logger = pino();
7-
logger.level = config.log.level;
7+
logger.level = process.env.LOG_LEVEL || config.log.level;
88

99
const { threadId } = require('worker_threads');
1010

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "imapapi",
33
"private": true,
4-
"version": "1.2.6",
4+
"version": "1.2.7",
55
"description": "Email Sync Engine",
66
"main": "server.js",
77
"scripts": {
@@ -23,6 +23,7 @@
2323
"@popperjs/core": "2.2.1",
2424
"bootstrap": "4.4.1",
2525
"bull": "3.13.0",
26+
"dotenv": ".value8.2.0",
2627
"email-reply-parser": "1.2.2",
2728
"exponential-backoff": "3.0.0",
2829
"hapi-pino": "7.0.0",

server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
require('dotenv').config();
4+
35
process.title = 'imapapi';
46

57
// cache before wild-config

workers/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ parentPort.on('message', message => {
232232

233233
const init = async () => {
234234
const server = Hapi.server({
235-
port: config.api.port,
236-
host: config.api.host,
235+
port: (process.env.API_PORT && Number(process.env.API_PORT)) || config.api.port,
236+
host: process.env.API_HOST || config.api.host,
237237
query: {
238238
parser: query => qs.parse(query, { depth: 3 })
239239
}

0 commit comments

Comments
 (0)