Compare commits

4 Commits

Author SHA1 Message Date
rxf
99678ae1be Statur Route dazu (server.js) 2026-03-17 09:03:04 +01:00
rxf
4f3f9f842c . 2026-03-17 09:01:59 +01:00
rxf
9edfb87233 docker compose in das Root-Verzeichnis gelegt 2026-03-17 09:01:51 +01:00
rxf
2d83276a27 Deleted Flag eingeführt 2026-01-14 07:41:14 +01:00
3 changed files with 26 additions and 10 deletions

View File

@@ -30,13 +30,24 @@ app.use(express.json());
// API ROUTEN
// -----------------------------------------------------
// Root-Route zur Status-Überprüfung
app.get('/', (req, res) => {
res.json({
message: 'Appointment API Server läuft',
status: 'ok',
endpoints: {
appointments: '/api/appointments'
}
});
});
// 1. READ: Alle Termine abrufen (GET /api/appointments)
app.get('/api/appointments', async (req, res) => {
try {
const db = getDb();
// Finde alle Dokumente in der Collection 'appointments'
// Finde alle Dokumente in der Collection 'appointments', die nicht gelöscht sind
const appointments = await db.collection('appointments')
.find({})
.find({ deleted: { $ne: true } })
// Optional: Nach Termindatum sortieren (aufsteigend)
.sort({ termin: 1 })
.toArray();
@@ -112,6 +123,7 @@ app.put('/api/appointments/:id', async (req, res) => {
});
// 4. DELETE: Termin löschen (DELETE /api/appointments/:id)
// Soft Delete: Setzt das deleted-Flag statt den Eintrag zu löschen
app.delete('/api/appointments/:id', async (req, res) => {
try {
const db = getDb();
@@ -119,9 +131,13 @@ app.delete('/api/appointments/:id', async (req, res) => {
const filter = { _id: new ObjectId(id) };
const result = await db.collection('appointments').deleteOne(filter);
// Setze das deleted-Flag auf true statt den Eintrag zu löschen
const result = await db.collection('appointments').updateOne(
filter,
{ $set: { deleted: true, deletedAt: new Date() } }
);
if (result.deletedCount === 0) {
if (result.matchedCount === 0) {
return res.status(404).json({ message: "Termin nicht gefunden." });
}

View File

@@ -17,7 +17,7 @@ services:
backend:
build:
context: .
context: ./backend
dockerfile: Dockerfile
container_name: backend
restart: unless-stopped
@@ -29,14 +29,14 @@ services:
depends_on:
- mongodb
volumes:
- ./src:/app/src
- ./package.json:/app/package.json
- ./backend/src:/app/src
- ./backend/package.json:/app/package.json
networks:
- app-network
frontend:
build:
context: ../frontend
context: ./frontend
dockerfile: Dockerfile
container_name: frontend
restart: unless-stopped
@@ -45,8 +45,8 @@ services:
depends_on:
- backend
volumes:
- ../frontend/src:/app/src
- ../frontend/package.json:/app/package.json
- ./frontend/src:/app/src
- ./frontend/package.json:/app/package.json
networks:
- app-network