Skip to content

Commit

Permalink
fix: the versioned api should serve the encrypted files
Browse files Browse the repository at this point in the history
  • Loading branch information
vjousse committed Dec 9, 2024
1 parent 2329235 commit 9eeaeb5
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,11 @@ version.get("/:versionNumber/api", checkVersionAndPath, (req, res) => {
});

version.all("/:versionNumber/api/*", checkVersionAndPath, bodyParser.json(), async (req, res) => {
const foodProcesses = fs
.readFileSync(path.join(req.staticDir, "data", "food", "processes_impacts.json"))
.toString();
const objectProcesses = fs
.readFileSync(path.join(req.staticDir, "data", "object", "processes_impacts.json"))
.toString();
const textileProcesses = fs
.readFileSync(path.join(req.staticDir, "data", "textile", "processes_impacts.json"))
.toString();

const processes = { foodProcesses, objectProcesses, textileProcesses };
const versionNumber = req.params.versionNumber;
const { processesImpacts, processes } = availableVersions.find(
(version) => version.dir === versionNumber,
);
const versionProcesses = await getProcesses(req.headers.token, processesImpacts, processes);

const { Elm } = require(path.join(req.staticDir, "server-app"));

Expand All @@ -301,7 +295,7 @@ version.all("/:versionNumber/api/*", checkVersionAndPath, bodyParser.json(), asy
method: req.method,
url: urlWithoutPrefix,
body: req.body,
processes,
processes: versionProcesses,
jsResponseHandler: ({ status, body }) => {
res.status(status).send(body);
},
Expand Down

0 comments on commit 9eeaeb5

Please sign in to comment.