feat: add production auth and diagnosis schema
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user