2024-09-17 20:56:59 +02:00
|
|
|
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,
|
2024-10-01 23:29:09 +02:00
|
|
|
refreshIntervalSeconds: process.env.IMAP_REFRESH_INTERVAL_SECONDS || 60
|
2024-09-17 20:56:59 +02:00
|
|
|
},
|
|
|
|
http: {
|
2024-10-01 23:29:09 +02:00
|
|
|
port: normalizePort(process.env.HTTP_PORT || 3000),
|
2024-10-02 02:36:25 +02:00
|
|
|
branding: process.env.HTTP_BRANDING || ["48hr.email", "CrazyCo", "https://crazyco.xyz"],
|
|
|
|
examples: process.env.HTTP_EXAMPLES || {
|
|
|
|
email: "example@48hr.email",
|
|
|
|
ids: [1, 2, 3]
|
|
|
|
}
|
2024-09-17 20:56:59 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-10-01 23:29:09 +02:00
|
|
|
module.exports = config;
|