From e5d12fb8d5c81d5f36cd439f401827c506ac71b7 Mon Sep 17 00:00:00 2001 From: BorisTherin Date: Fri, 29 Mar 2024 12:00:39 +0100 Subject: [PATCH] fonction back to classes --- src/ingesters/download.ts | 22 -------------------- src/ingesters/handleDir.ts | 8 ------- src/ingesters/index.ts | 1 - src/{ingesters => transformers}/Transform.ts | 0 src/transformers/index.ts | 1 + 5 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 src/ingesters/download.ts delete mode 100644 src/ingesters/handleDir.ts rename src/{ingesters => transformers}/Transform.ts (100%) create mode 100644 src/transformers/index.ts diff --git a/src/ingesters/download.ts b/src/ingesters/download.ts deleted file mode 100644 index 9f7e3cc..0000000 --- a/src/ingesters/download.ts +++ /dev/null @@ -1,22 +0,0 @@ -import * as fs from "node:fs" - -const baseUrl = "https://raw.githubusercontent.com/decoderleco/deces_europe/main/data/csv/" -const format = "" - -export async function download(remote: string, rawPath: string){ - const res = await fetch( baseUrl + remote + format) - const text = await res.text() - try { - fs.writeFileSync( rawPath, text, - { - encoding: 'utf8', - flag: 'w', - mode: 0o666 - }, - ) - console.log("le fichier " + baseUrl + remote + "a été telechargé dans " + rawPath) - return('file downloaded') - } catch (err) { - return("error while writing " + rawPath + remote + ": " + err) - } -} diff --git a/src/ingesters/handleDir.ts b/src/ingesters/handleDir.ts deleted file mode 100644 index 97c18da..0000000 --- a/src/ingesters/handleDir.ts +++ /dev/null @@ -1,8 +0,0 @@ -import * as fs from "node:fs" - -export async function createDirs(rawPath :string) { - if (fs.existsSync(rawPath.split("/")[1]) == false) { - fs.mkdirSync( rawPath.split("/")[1]) - console.log("mkdir " + rawPath.split("/")[1] ) - } -} \ No newline at end of file diff --git a/src/ingesters/index.ts b/src/ingesters/index.ts index 9a714a1..dabd30d 100644 --- a/src/ingesters/index.ts +++ b/src/ingesters/index.ts @@ -1,2 +1 @@ -export * from './Transform' export * from './DecoderLecoGithubDataIngester' diff --git a/src/ingesters/Transform.ts b/src/transformers/Transform.ts similarity index 100% rename from src/ingesters/Transform.ts rename to src/transformers/Transform.ts diff --git a/src/transformers/index.ts b/src/transformers/index.ts new file mode 100644 index 0000000..37018ed --- /dev/null +++ b/src/transformers/index.ts @@ -0,0 +1 @@ +export * from './Transform' \ No newline at end of file