Skip to content

Commit 9e87f7b

Browse files
missions.js aktualisieren
1 parent cff7192 commit 9e87f7b

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

api/routes/missions.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import express from "express";
22
import multer from "multer";
3-
import path from "path";
3+
import path from "node:path";
44
import fs from "fs";
55

66
import { v4 as uuidv4 } from "uuid";
77
import { store } from "../../data/store.js";
88
import { parseAoiFileToFeatureCollection, computeAreaKm2 } from "../../services/aoi/aoi.js";
99
import { planMissionFromAoi } from "../../services/planner/planner.js";
1010
import { startProcessingJob } from "../../services/processing/webodm.js";
11+
import { chainAppend, hashFileSha256 } from "../../services/chain/chain-client.js";
1112

1213
const router = express.Router();
1314

@@ -79,6 +80,34 @@ router.post("/", upload.single("aoi"), async (req, res) => {
7980
processing: { state: "idle", outputs: {} },
8081
});
8182

83+
// --- Chain audit: MISSION_CREATED ---
84+
try {
85+
const aoiStoredPath = req.file.path;
86+
const aoiHash = await hashFileSha256(aoiStoredPath);
87+
88+
await chainAppend({
89+
event: "MISSION_CREATED",
90+
at: new Date().toISOString(),
91+
mission: {
92+
id: mission.id,
93+
name: mission.name,
94+
areaKm2: mission.areaKm2,
95+
camera: mission.camera,
96+
gsdCmPerPx: mission.gsdCmPerPx,
97+
overlapPct: mission.overlapPct,
98+
speedMps: mission.speedMps,
99+
},
100+
aoi: {
101+
originalName: req.file.originalname,
102+
storedName: path.basename(aoiStoredPath),
103+
sha256: aoiHash,
104+
},
105+
plan: mission.plan?.derived || null,
106+
});
107+
} catch (e) {
108+
console.warn("[Chain] MISSION_CREATED append failed:", e?.message || e);
109+
}
110+
82111
res.status(201).json(mission);
83112
} catch (e) {
84113
console.error("[missions.create] error:", e);
@@ -106,4 +135,4 @@ router.post("/:id/process", async (req, res) => {
106135
}
107136
});
108137

109-
export default router;
138+
export default router;

0 commit comments

Comments
 (0)