kundencenter/ops/dev/seed.mjs
Claude (KI) 546e667081 Ein-Befehl-Entwicklungsstack mit Mailpit (#14)
ops/dev/run.sh: MariaDB (Volume), Mailpit, API/Worker/Web im Watch-Modus,
Migrationen und idempotente Testdaten (Superadmin, SMTP → Mailpit), nur
Dummy-Konfiguration. Probelauf: Web nach 20 s erreichbar, Login ok,
Passwort-vergessen-Mail kommt in Mailpit an. README ergänzt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 13:00:57 +02:00

15 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Testdaten für den Entwicklungsstack (idempotent): Superadmin und SMTP → Mailpit.
// Anmeldung: dev@kundencenter.local / entwicklung-passwort-123 (2FA wird beim ersten Login eingerichtet).
import { createRequire } from 'node:module';
const require = createRequire(new URL('../../apps/api/package.json', import.meta.url));
const mysql = require('mysql2/promise');
const { hash } = require('@node-rs/argon2');
const c = await mysql.createConnection({ host: process.env.DB_HOST, user: process.env.DB_USER, password: process.env.DB_PASSWORD, database: process.env.DB_NAME });
const [[u]] = await c.query("SELECT id FROM users WHERE email = 'dev@kundencenter.local'");
if (!u) {
await c.query("INSERT INTO users (id, email, name, password_hash, kind, staff_role, status, email_verified_at) VALUES (UUID(), 'dev@kundencenter.local', 'Entwicklung', ?, 'staff', 'superadmin', 'active', UTC_TIMESTAMP(3))", [await hash('entwicklung-passwort-123')]);
console.log('Superadmin angelegt: dev@kundencenter.local / entwicklung-passwort-123');
}
await c.query("UPDATE smtp_settings SET host = 'mailpit', port = 1025, secure_mode = 'none', from_name = 'Kundencenter (Entwicklung)', from_email = 'kundencenter@dev.local' WHERE id = 1");
await c.end();
console.log('Entwicklungsdaten bereit – Kundencenter http://127.0.0.1:4101 , Mailpit http://127.0.0.1:8025');