feat!: Download and extract from stream

This commit is contained in:
Lucàs
2024-09-24 14:35:30 +02:00
parent 0382499c0d
commit 5a00871319
18 changed files with 249 additions and 251 deletions
+1 -12
View File
@@ -1,20 +1,9 @@
import { Router, Request, Response } from "express";
import fileService from "../../services/fileService";
const router = Router();
router.get("/data/nudger", (req: Request, res: Response) => {
fileService
.downloadAndExtract("https://nudger.fr/opendata/gtin-open-data.zip")
.then(() => {
res.status(200).json({
status: "SUCCESS",
message: "Data nudger downloaded and extracted",
});
})
.catch((error) => {
res.status(500).json({ status: "ERROR", message: error.message });
});
res.status(501).send("Not yet implemented");
});
export default router;
+1 -14
View File
@@ -1,22 +1,9 @@
import { Router, Request, Response } from "express";
import fileService from "../../services/fileService";
const router = Router();
router.get("/data/openfoodfacts", (req: Request, res: Response) => {
fileService
.downloadAndExtract(
"https://static.openfoodfacts.org/data/en.openfoodfacts.org.products.csv.gz"
)
.then(() => {
res.status(200).json({
status: "SUCCESS",
message: "Data openfoodfacts downloaded and extracted",
});
})
.catch((error) => {
res.status(500).json({ status: "ERROR", message: error.message });
});
res.status(501).send("Not yet implemented");
});
export default router;