feat: add fullstack TypeScript template with Docker support
- Created package.json for managing workspaces (frontend and backend) - Added scripts for development, build, testing, and Docker operations - Implemented kill-dev-processes.sh script to terminate development processes gracefully
This commit is contained in:
50
backend/src/index.ts
Normal file
50
backend/src/index.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3001;
|
||||
|
||||
// Middleware
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
// Routes
|
||||
app.get("/api/health", (req, res) => {
|
||||
// 🐛 Breakpoint-Test: Setze hier einen Breakpoint zum Testen
|
||||
console.log("Health check aufgerufen!");
|
||||
|
||||
res.json({
|
||||
status: "OK",
|
||||
message: "Backend is running",
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/api/photos", (req, res) => {
|
||||
// Beispiel-Endpunkt für Fotos
|
||||
res.json({
|
||||
photos: [
|
||||
{ id: 1, name: "photo1.jpg", url: "/images/photo1.jpg" },
|
||||
{ id: 2, name: "photo2.jpg", url: "/images/photo2.jpg" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
app.post("/api/print", (req, res) => {
|
||||
// Beispiel-Endpunkt für Druckaufträge
|
||||
const { photoId, copies } = req.body;
|
||||
|
||||
console.log(`Druckauftrag erhalten: Photo ID ${photoId}, Kopien: ${copies}`);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: `Druckauftrag für Photo ${photoId} mit ${copies} Kopien wurde erstellt`,
|
||||
jobId: Math.random().toString(36).substr(2, 9),
|
||||
});
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 Backend Server läuft auf Port ${PORT}`);
|
||||
console.log(`📍 Health Check: http://localhost:${PORT}/api/health`);
|
||||
console.log(`🐛 Debugger bereit auf Port 9229`);
|
||||
});
|
||||
Reference in New Issue
Block a user