feat: add production auth and diagnosis schema

This commit is contained in:
Asep Haryana Saputra
2026-05-22 15:53:48 +00:00
parent b347ed4fd1
commit 794abfdb35
4 changed files with 117 additions and 2 deletions
+28
View File
@@ -1,4 +1,32 @@
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,
);
export const env = {
port: Number(Bun.env.API_PORT ?? 3000),
databaseUrl: Bun.env.DATABASE_URL,
sessionSecret: Bun.env.SESSION_SECRET,
uploaderBaseUrl: Bun.env.UPLOADER_BASE_URL ?? 'https://upload.asepharyana.tech',
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,
webAppUrl: Bun.env.WEB_APP_URL ?? 'http://localhost:5173',
};
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');
}
}