mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 01:39:39 +02:00
Backend: Hono/Bun service on port 3042 with JMAP client for Stalwart, account provisioning (@mana.how addresses on user registration), thread/message/send/label API endpoints, and JWT + service-key auth. Frontend: Mail module with 3-column inbox UI (mailboxes, thread list, detail/compose), local-first encrypted drafts in Dexie, and API-driven thread fetching. Scoped CSS with theme tokens. Integration: Dexie v11 schema, mail pgSchema in mana_platform, mana-auth fire-and-forget hook for account provisioning, getManaMailUrl() in API config, app registry + branding update. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
/**
|
|
* Application configuration loaded from environment variables.
|
|
*/
|
|
|
|
export interface Config {
|
|
port: number;
|
|
databaseUrl: string;
|
|
manaAuthUrl: string;
|
|
serviceKey: string;
|
|
baseUrl: string;
|
|
stalwart: {
|
|
jmapUrl: string;
|
|
adminUser: string;
|
|
adminPassword: string;
|
|
domain: string;
|
|
};
|
|
smtp: {
|
|
host: string;
|
|
port: number;
|
|
user: string;
|
|
password: string;
|
|
from: string;
|
|
insecureTls: boolean;
|
|
};
|
|
cors: {
|
|
origins: string[];
|
|
};
|
|
}
|
|
|
|
export function loadConfig(): Config {
|
|
const requiredEnv = (key: string, fallback?: string): string => {
|
|
const value = process.env[key] || fallback;
|
|
if (!value) throw new Error(`Missing required env var: ${key}`);
|
|
return value;
|
|
};
|
|
|
|
return {
|
|
port: parseInt(process.env.PORT || '3042', 10),
|
|
databaseUrl: requiredEnv(
|
|
'DATABASE_URL',
|
|
'postgresql://mana:devpassword@localhost:5432/mana_platform'
|
|
),
|
|
manaAuthUrl: requiredEnv('MANA_AUTH_URL', 'http://localhost:3001'),
|
|
serviceKey: requiredEnv('MANA_SERVICE_KEY', 'dev-service-key'),
|
|
baseUrl: requiredEnv('BASE_URL', 'http://localhost:3042'),
|
|
stalwart: {
|
|
jmapUrl: requiredEnv('STALWART_JMAP_URL', 'http://localhost:8080'),
|
|
adminUser: requiredEnv('STALWART_ADMIN_USER', 'admin'),
|
|
adminPassword: requiredEnv('STALWART_ADMIN_PASSWORD', 'ChangeMe123!'),
|
|
domain: requiredEnv('MAIL_DOMAIN', 'mana.how'),
|
|
},
|
|
smtp: {
|
|
host: process.env.SMTP_HOST || 'localhost',
|
|
port: parseInt(process.env.SMTP_PORT || '587', 10),
|
|
user: process.env.SMTP_USER || 'noreply',
|
|
password: process.env.SMTP_PASSWORD || '',
|
|
from: process.env.SMTP_FROM || 'Mana <noreply@mana.how>',
|
|
insecureTls: process.env.SMTP_INSECURE_TLS === 'true',
|
|
},
|
|
cors: {
|
|
origins: (process.env.CORS_ORIGINS || 'http://localhost:5173').split(','),
|
|
},
|
|
};
|
|
}
|