2026-05-22 15:53:48 +00:00
|
|
|
const uploadAllowedMimeTypes = (Bun.env.UPLOAD_ALLOWED_MIME_TYPES ?? 'image/jpeg,image/png')
|
|
|
|
|
.split(',')
|
|
|
|
|
.map((value) => value.trim())
|
|
|
|
|
.filter(Boolean);
|
|
|
|
|
|
|
|
|
|
const googleOAuthEnabled = Boolean(
|
|
|
|
|
Bun.env.GOOGLE_CLIENT_ID && Bun.env.GOOGLE_CLIENT_SECRET && Bun.env.GOOGLE_REDIRECT_URI,
|
|
|
|
|
);
|
|
|
|
|
|
2026-05-22 17:32:57 +00:00
|
|
|
const webAppUrl = Bun.env.WEB_APP_URL ?? 'http://localhost:5173';
|
2026-06-15 14:32:54 +07:00
|
|
|
const allowedOrigins = [
|
|
|
|
|
webAppUrl,
|
|
|
|
|
'https://tauri.localhost',
|
|
|
|
|
'tauri://localhost',
|
|
|
|
|
'http://localhost:5173',
|
|
|
|
|
];
|
2026-05-22 17:32:57 +00:00
|
|
|
const secureCookies = Bun.env.SECURE_COOKIES === 'true' || webAppUrl.startsWith('https://');
|
|
|
|
|
|
2026-05-22 12:25:41 +00:00
|
|
|
export const env = {
|
|
|
|
|
port: Number(Bun.env.API_PORT ?? 3000),
|
|
|
|
|
databaseUrl: Bun.env.DATABASE_URL,
|
2026-05-22 15:53:48 +00:00
|
|
|
sessionSecret: Bun.env.SESSION_SECRET,
|
2026-06-08 01:53:02 +07:00
|
|
|
uploaderBaseUrl: Bun.env.UPLOADER_BASE_URL ?? 'https://upload.asepharyana.my.id',
|
|
|
|
|
// Note: was 'https://upload.asepharyana.tech' — .tech domain is dead, changed to .my.id
|
2026-05-22 19:50:25 +00:00
|
|
|
mlServiceUrl: Bun.env.ML_SERVICE_URL ?? 'http://127.0.0.1:8001',
|
2026-05-22 15:53:48 +00:00
|
|
|
uploadMaxBytes: Number(Bun.env.UPLOAD_MAX_BYTES ?? 5 * 1024 * 1024),
|
|
|
|
|
uploadAllowedMimeTypes,
|
|
|
|
|
googleOAuthEnabled,
|
|
|
|
|
googleClientId: Bun.env.GOOGLE_CLIENT_ID,
|
|
|
|
|
googleClientSecret: Bun.env.GOOGLE_CLIENT_SECRET,
|
|
|
|
|
googleRedirectUri: Bun.env.GOOGLE_REDIRECT_URI,
|
2026-05-22 17:32:57 +00:00
|
|
|
webAppUrl,
|
2026-06-15 14:32:54 +07:00
|
|
|
allowedOrigins,
|
2026-05-22 17:32:57 +00:00
|
|
|
secureCookies,
|
2026-05-22 12:25:41 +00:00
|
|
|
};
|
2026-05-22 15:53:48 +00:00
|
|
|
|
|
|
|
|
export function assertRequiredEnv() {
|
|
|
|
|
if (!env.databaseUrl) {
|
|
|
|
|
throw new Error('DATABASE_URL is required');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!env.sessionSecret || env.sessionSecret.length < 32) {
|
|
|
|
|
throw new Error('SESSION_SECRET is required and must be at least 32 characters');
|
|
|
|
|
}
|
|
|
|
|
}
|