Optimisations + lisibilité

This commit is contained in:
Sébastien Rivière
2025-06-18 02:21:32 +02:00
parent c6066bc234
commit 4fd73a35c8
9 changed files with 153 additions and 187 deletions

View File

@@ -13,7 +13,7 @@ const ALLOWED_MIME = [
"image/gif"
]
//Setup multer (the file upload middleware)
// Setup multer (the file upload middleware)
const storage = multer.diskStorage({
// Save the file in the uploads directory
destination: function (req, file, callback) {
@@ -27,7 +27,7 @@ const storage = multer.diskStorage({
const upload = multer({
storage,
//Only upload the file if it is a valid mime type and the team POST parameter is a valid team
// Only upload the file if it is a valid mime type and the team POST parameter is a valid team
fileFilter: function (req, file, callback) {
if (ALLOWED_MIME.indexOf(file.mimetype) == -1) {
callback(null, false);
@@ -39,8 +39,7 @@ const upload = multer({
}
})
//Clean the uploads directory
// Clean the uploads directory
function clean() {
const files = fs.readdirSync(UPLOAD_DIR);
for (const file of files) {
@@ -49,7 +48,6 @@ function clean() {
}
}
export function initPhotoUpload() {
clean();
//App handler for uploading a photo and saving it to a file