38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { mkdir } from "node:fs/promises";
|
|
import {castCommentsConfig, type CommentsConfig} from "./types.ts";
|
|
|
|
const maybeConfig: any = {
|
|
mail: {
|
|
refreshIntervalInSeconds: process.env.CHROUS_REFRESH_INTERVAL_IN_SECONDS || 60,
|
|
imap: {
|
|
host: process.env.CHORUS_IMAP_HOST,
|
|
port: process.env.CHORUS_IMAP_PORT || 993,
|
|
auth: {
|
|
user: process.env.CHORUS_IMAP_USER,
|
|
pass: process.env.CHORUS_IMAP_PASS,
|
|
},
|
|
mailbox: process.env.CHORUS_MAILBOX,
|
|
},
|
|
threads: {
|
|
type: 'alias',
|
|
template: process.env.CHORUS_THREAD_TEMPLATE,
|
|
idPrefix: 'c.',
|
|
replyPrefix: '.r.',
|
|
},
|
|
},
|
|
dirs: {
|
|
data: process.env.CHORUS_DATA_DIR || 'chorus-data',
|
|
},
|
|
http: {
|
|
enabled: process.env.CHORUS_HTTP_ENABLE === 'true',
|
|
address: process.env.CHORUS_HTTP_ADDRESS || '0.0.0.0',
|
|
port: process.env.CHORUS_HTTP_PORT || 8101,
|
|
},
|
|
}
|
|
|
|
export const config: CommentsConfig = castCommentsConfig(maybeConfig)
|
|
|
|
export async function ensureDirectoriesExist(): Promise<void> {
|
|
await mkdir(`${config.dirs.data}/threads`, { recursive: true })
|
|
}
|