From 99c14e070cac2380877aa0a41d618edec9eb9502 Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Tue, 17 Sep 2024 20:49:53 +0200 Subject: [PATCH 1/4] i hate git --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 23038f4..de45fd8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ node_modules .idea .DS_Store .vscode -application/config.js From 436a13ff14233d8d32d784625fffefa1e94ff83f Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Tue, 17 Sep 2024 20:56:59 +0200 Subject: [PATCH 2/4] Update sample --- .gitignore | 1 + application/config.sample.js | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 application/config.sample.js diff --git a/.gitignore b/.gitignore index de45fd8..2480aa1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .idea .DS_Store .vscode +application/config.js \ No newline at end of file diff --git a/application/config.sample.js b/application/config.sample.js new file mode 100644 index 0000000..acbdf6f --- /dev/null +++ b/application/config.sample.js @@ -0,0 +1,51 @@ +// Note: Also update app.json and README.md! + +const config = { + email: { + domains: process.env.EMAIL_DOMAINS, + deleteMailsOlderThanDays: process.env.EMAIL_DELETE_MAILS_OLDER_THAN_DAYS || 2 + }, + imap: { + user: process.env.IMAP_USER, + password: process.env.IMAP_PASSWORD, + host: process.env.IMAP_SERVER, + port: process.env.IMAP_PORT || 993, + tls: process.env.IMAP_TLS || true, + authTimeout: process.env.IMAP_AUTHTIMEOUT || 3000, + refreshIntervalSeconds: process.env.IMAP_REFRESH_INTERVAL_SECONDS || 10 + }, + http: { + port: normalizePort(process.env.HTTP_PORT || '3000'), + branding: process.env.HTTP_BRANDING || ["48hr.email", "CrazyCo", "https://crazyco.xyz"] + }, +} + +if (!config.imap.user || !config.imap.password || !config.imap.host) { + throw new Error('IMAP is not configured. Use IMAP_* ENV vars.') +} + +if (!config.email.domains) { + throw new Error('DOMAINS is not configured. Use ENV vars.') +} + +/** + * Normalize a port into a number, string, or false. + */ + +function normalizePort(val) { + const port = parseInt(val, 10) + + if (isNaN(port)) { + // Named pipe + return val + } + + if (port >= 0) { + // Port number + return port + } + + return false +} + +module.exports = config; \ No newline at end of file From c4521c46af260045c0d27c3697ddcbb40582b3b0 Mon Sep 17 00:00:00 2001 From: Clara K Date: Tue, 17 Sep 2024 21:01:23 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2558b35..60b6b96 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,8 @@ All data is being removed 48hrs after they have reached the mail server. - `cd 48hr.email` - `npm i` - Change all settings to the desired values: - - Either use environmental variables, or modify `application/config.js` + - Either use environmental variables, or modify `application/config.sample.js` (Rename to `config.js` after) + - For a list of values, check `application/config.sample.js`. - `npm run start` - #### Service file example: From d1a8440b4e17fb6e0fd060980d8f2b44759c42ca Mon Sep 17 00:00:00 2001 From: Clara K Date: Tue, 17 Sep 2024 21:01:59 +0200 Subject: [PATCH 4/4] Delete application/config.js --- application/config.js | 49 ------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 application/config.js diff --git a/application/config.js b/application/config.js deleted file mode 100644 index a779b93..0000000 --- a/application/config.js +++ /dev/null @@ -1,49 +0,0 @@ -// Note: Also update app.json and README.md! - -const config = { - email: { - domains: process.env.DOMAINS, - deleteMailsOlderThanDays: process.env.DELETE_MAILS_OLDER_THAN_DAYS - }, - imap: { - user: process.env.IMAP_USER, - password: process.env.IMAP_PASSWORD, - host: process.env.IMAP_SERVER, - port: 993, - tls: true, - authTimeout: 3000, - refreshIntervalSeconds: process.env.IMAP_REFRESH_INTERVAL_SECONDS - }, - http: {port: normalizePort(process.env.PORT || '3000')}, - branding: process.env.BRANDING || ["PROJECT_NAME", "YOUR_NAME", "YOUR_WEBSITE"] -} - -if (!config.imap.user || !config.imap.password || !config.imap.host) { - throw new Error('IMAP is not configured. Use IMAP_* ENV vars.') -} - -if (!config.email.domains) { - throw new Error('DOMAINS is not configured. Use ENV vars.') -} - -/** - * Normalize a port into a number, string, or false. - */ - -function normalizePort(val) { - const port = parseInt(val, 10) - - if (isNaN(port)) { - // Named pipe - return val - } - - if (port >= 0) { - // Port number - return port - } - - return false -} - -module.exports = config