chore: echte Appwrite-Projekt-ID übernehmen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-04 09:38:32 +00:00
1 parent 38b361ad7a
commit 94f6d74249
7 files changed
+49 -24

No files matched your search

+19 -7
View File
@@ -29,7 +29,6 @@
import { pathToFileURL } from 'node:url';
export const DEFAULT_ENDPOINT = 'https://appwrite.webklar.com/v1';
const PROJECT = 'aircard';
// ---------------------------------------------------------------------------
// Soll-Zustand
@@ -166,11 +165,11 @@ function createApi({ endpoint, key, project }) {
}
/** Klare deutsche Meldung für eine unerwartete Antwort. */
function describeFailure(status, body, what) {
function describeFailure(status, body, what, project) {
const detail = [body?.type, body?.message].filter((part) => typeof part === 'string' && part).join(': ');
const tail = detail ? ` Server: ${detail}` : '';
if (status === 404 && body?.type === 'project_not_found') {
return `Das Projekt „${PROJECT}“ existiert auf dem Server nicht. Bitte zuerst docs/appwrite-console.md abarbeiten (Projekt mit der ID „${PROJECT}“ anlegen).`;
return `Das Projekt „${project}” existiert auf dem Server nicht. Bitte zuerst docs/appwrite-console.md abarbeiten und die AIRCARD_APPWRITE_PROJECT_ID in /home/webklar/apps/.env prüfen.`;
}
if (status === 401 || status === 403) {
return `${what}: Zugriff verweigert (HTTP ${status}). API-Key und Scopes prüfen (databases, tables, columns, buckets – jeweils read/write).${tail}`;
@@ -184,13 +183,13 @@ async function getObject(ctx, path, what) {
const res = await ctx.api('GET', path);
if (res.status === 200) return res.body;
if (isMissing(res.status, res.body)) return null;
throw new SetupError(describeFailure(res.status, res.body, what));
throw new SetupError(describeFailure(res.status, res.body, what, ctx.project));
}
async function createObject(ctx, path, body, what) {
const res = await ctx.api('POST', path, body);
if (res.status >= 200 && res.status < 300) return res.body;
throw new SetupError(describeFailure(res.status, res.body, what));
throw new SetupError(describeFailure(res.status, res.body, what, ctx.project));
}
// ---------------------------------------------------------------------------
@@ -359,18 +358,22 @@ export async function ensureBucket(ctx) {
export async function main({
endpoint = DEFAULT_ENDPOINT,
key,
project = PROJECT,
project,
check = false,
log = console.log,
pollMs = 1000,
timeoutMs = 30_000,
} = {}) {
if (!project) {
throw new SetupError('project-Parameter erforderlich');
}
const stats = { missing: 0, deviations: 0 };
const ctx = {
api: createApi({ endpoint, key, project }),
check,
pollMs,
timeoutMs,
project,
ok: (label) => log(`OK: ${label}`),
created: (label) => log(`ANGELEGT: ${label}`),
missing: (label) => {
@@ -426,7 +429,15 @@ async function cli() {
const key = process.env.AIRCARD_APPWRITE_API_KEY?.trim();
if (!key) {
console.error('Fehler: AIRCARD_APPWRITE_API_KEY fehlt.');
console.error('Den API-Key „aircard-provision“ als Zeile AIRCARD_APPWRITE_API_KEY=… in /home/webklar/apps/.env eintragen (siehe docs/appwrite-console.md)');
console.error('Den API-Key „aircard-provision” als Zeile AIRCARD_APPWRITE_API_KEY=… in /home/webklar/apps/.env eintragen (siehe docs/appwrite-console.md)');
console.error('und das Skript mit --env-file=/home/webklar/apps/.env starten.');
process.exitCode = 2;
return;
}
const project = process.env.AIRCARD_APPWRITE_PROJECT_ID?.trim();
if (!project) {
console.error('Fehler: AIRCARD_APPWRITE_PROJECT_ID fehlt.');
console.error('Die Projekt-ID als Zeile AIRCARD_APPWRITE_PROJECT_ID=6ac2130a00289343d6d5 in /home/webklar/apps/.env eintragen.');
console.error('und das Skript mit --env-file=/home/webklar/apps/.env starten.');
process.exitCode = 2;
return;
@@ -434,6 +445,7 @@ async function cli() {
process.exitCode = await main({
endpoint: process.env.AIRCARD_APPWRITE_ENDPOINT || DEFAULT_ENDPOINT,
key,
project,
check: args.includes('--check'),
});
}