Compare commits

...

3 Commits

  1. 6
      Dockerfile
  2. 54
      src/models/file.js

6
Dockerfile

@ -12,6 +12,9 @@ RUN mkdir -p /home/node/app/node_modules
WORKDIR /home/node/app
# Copie des fichiers de configuration de Webpack
COPY webpack.config.js ./
COPY package*.json ./
RUN npm install
@ -20,6 +23,9 @@ RUN npm install nodemon --save-dev
COPY . .
#COPY .env .
# Compilation des fichiers JS et SASS avec Webpack
RUN npm run build
EXPOSE 3100
CMD [ "npm", "run", "dev" ]

54
src/models/file.js

@ -79,58 +79,6 @@ class File {
});
}
formatDateToCustomFormat(date) {
// Obtenir les composantes de la date et de l'heure
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0"); // Janvier est 0, février est 1, etc.
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
// Créer la chaîne au format personnalisé
const formattedDate = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
return formattedDate;
}
// Create a generateFilePath function witch returns a path with a filename and datetime
generateFilePath(filename) {
const date = new Date();
return {
filepath: path.join(
dest,
`${filename}-${this.formatDateToCustomFormat(date)}.csv`
),
generatedpath: path.join(
dest,
`${filename}-generated-${this.formatDateToCustomFormat(date)}.csv`
),
};
}
/**
* Download a file from a url
* @returns {Promise<string>} filepath
*/
async fakeDownload() {
const url = URL.parse(this.url);
this.filename = slugify(url.hostname, { lower: true });
const filepath = path.join(
dest,
`bodacc-datadila.opendatasoft.com-1697536785170.csv`
);
const generatedpath = path.join(
dest,
`bodacc-datadila.opendatasoft.com-generated-1697536785170-2.csv`
);
this.filepath = filepath;
this.generatedpath = generatedpath;
return new Promise((resolve, reject) => {
resolve(filepath);
});
}
/**
* Download a file from a url
* @returns {Promise<string>} filepath
@ -436,7 +384,7 @@ class File {
}
}
return result.map((res) => {
return typeof res === "string" ? res.replace(/;/g, ",") : res;
return typeof res === "string" ? res.replace(/;/g, ",").replace("\n", "") : res;
});
}
}

Loading…
Cancel
Save