init push

This commit is contained in:
nadja
2026-08-25 20:29:14 +02:00
commit 2bb9aab82c
42 changed files with 3966 additions and 0 deletions

30
backend/server.js Normal file
View File

@@ -0,0 +1,30 @@
import express from 'express';
import cors from 'cors';
import bcrypt from 'bcryptjs';
import recipesRouter from './routes/recipes.js';
import authRouter from './routes/auth.js';
import { getUserByUsername, createUser } from './db.js';
const app = express();
const PORT = process.env.PORT || 3001;
app.use(cors());
app.use(express.json());
app.use('/api/auth', authRouter);
app.use('/api/recipes', recipesRouter);
const adminUser = process.env.ADMIN_USER || 'admin';
const adminPass = process.env.ADMIN_PASS || 'admin123';
const existing = getUserByUsername(adminUser);
if (!existing) {
const hashed = bcrypt.hashSync(adminPass, 10);
createUser(adminUser, hashed, true);
console.log(`Admin erstellt: ${adminUser} / ${adminPass}`);
console.log('WICHTIG: Passwort nach dem ersten Login ändern!');
}
app.listen(PORT, () => {
console.log(`Backend läuft auf http://localhost:${PORT}`);
});