fix: lazy env var check in server.ts — prevent module-level throw during Docker build

This commit is contained in:
egecankomur
2026-05-05 12:11:42 +03:00
parent 4ef0482732
commit 115e5cd159
+9 -11
View File
@@ -11,23 +11,21 @@ import {
Users,
} from "node-appwrite";
const endpoint = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT;
const projectId = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID;
const apiKey = process.env.APPWRITE_API_KEY;
if (!endpoint || !projectId) {
throw new Error(
"Missing NEXT_PUBLIC_APPWRITE_ENDPOINT or NEXT_PUBLIC_APPWRITE_PROJECT_ID. Check .env.local.",
);
}
export const APPWRITE_SESSION_COOKIE = "isletmem-session";
function baseClient() {
return new Client().setEndpoint(endpoint!).setProject(projectId!);
const endpoint = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT;
const projectId = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID;
if (!endpoint || !projectId) {
throw new Error(
"Missing NEXT_PUBLIC_APPWRITE_ENDPOINT or NEXT_PUBLIC_APPWRITE_PROJECT_ID.",
);
}
return new Client().setEndpoint(endpoint).setProject(projectId);
}
export function createAdminClient() {
const apiKey = process.env.APPWRITE_API_KEY;
if (!apiKey) {
throw new Error("Missing APPWRITE_API_KEY. Required for admin operations.");
}