2024-09-17 20:56:59 +02:00
|
|
|
const config = {
|
2024-10-04 23:32:21 +02:00
|
|
|
email: { // Email configuration
|
2024-10-05 02:02:02 +02:00
|
|
|
domains: process.env.EMAIL_DOMAINS || ['example.com', 'example.net'], // List object of domains
|
2024-10-03 02:14:47 +02:00
|
|
|
purgeTime: process.env.EMAIL_PURGE_TIME || {
|
2024-10-04 23:32:21 +02:00
|
|
|
time: 48, // Time value for when to purge
|
2024-10-03 01:22:10 +02:00
|
|
|
unit: 'hours', // minutes, hours, days
|
2024-10-04 23:32:21 +02:00
|
|
|
convert: true, // Convert to highest sensible unit (and round)
|
2024-10-21 01:52:33 +02:00
|
|
|
},
|
|
|
|
examples: process.env.EMAIL_EXAMPLES || { // Examples to use to demonstrate the service
|
|
|
|
account: "example@48hr.email", // example email to keep clean, besides the UIDs specified below
|
|
|
|
uids: [1, 2, 3] // example uids to keep
|
|
|
|
},
|
2024-09-17 20:56:59 +02:00
|
|
|
},
|
2024-10-04 23:32:21 +02:00
|
|
|
imap: { // IMAP configuration
|
2024-10-03 02:14:47 +02:00
|
|
|
user: process.env.IMAP_USER, // imap user
|
|
|
|
password: process.env.IMAP_PASSWORD, // imap password
|
|
|
|
host: process.env.IMAP_SERVER, // imap server
|
|
|
|
port: process.env.IMAP_PORT || 993, // imap port
|
|
|
|
tls: process.env.IMAP_TLS || true, // use secure connection?
|
|
|
|
authTimeout: process.env.IMAP_AUTHTIMEOUT || 3000, // timeout for auth
|
|
|
|
refreshIntervalSeconds: process.env.IMAP_REFRESH_INTERVAL_SECONDS || 60 // refresh interval
|
2024-09-17 20:56:59 +02:00
|
|
|
},
|
2024-10-04 23:32:21 +02:00
|
|
|
http: { // HTTP configuration
|
|
|
|
port: normalizePort(process.env.HTTP_PORT || 3000), // http port to listen on
|
2024-10-21 02:24:33 +02:00
|
|
|
branding: process.env.HTTP_BRANDING || ["48hr.email", "CrazyCo", "https://crazyco.xyz"], // branding [service_title, company_name, company_url]
|
2024-11-11 18:51:50 +01:00
|
|
|
displaySort: process.env.HTTP_DISPLAY_SORT || 0, // Sorting logic used for displaying available email domains:
|
2024-10-21 02:03:38 +02:00
|
|
|
// 0 does not modify,
|
|
|
|
// 1 sorts alphabetically,
|
|
|
|
// 2 sorts alphabetically and only shuffles the first item,
|
|
|
|
// 3 shuffles all
|
2024-11-11 18:51:50 +01:00
|
|
|
hideOther: process.env.HTTP_HIDE_OTHER || false, // Hide other email domains in the list and only show first (true) or show all (false)
|
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;
|