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:
29
backend/package.json
Normal file
29
backend/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "fullstack-typescript-template-backend",
|
||||
"version": "1.0.0",
|
||||
"description": "TypeScript Backend für Full Stack Template",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "ts-node-dev --respawn --transpile-only --inspect=0.0.0.0:9229 src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.11.24",
|
||||
"jest": "^29.7.0",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.3"
|
||||
}
|
||||
}
|
||||
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`);
|
||||
});
|
||||
36
backend/tsconfig.json
Normal file
36
backend/tsconfig.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "commonjs",
|
||||
"lib": ["ES2020"],
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"removeComments": false,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitThis": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"**/*.test.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user