created API For Aplication Absensi

This commit is contained in:
2025-10-14 14:08:11 +07:00
commit 96d206d892
56 changed files with 6533 additions and 0 deletions

24
app/middlewares/upload.js Normal file
View File

@@ -0,0 +1,24 @@
const multer = require("multer");
// ✅ Pakai memoryStorage → file masuk ke RAM, ada file.buffer
const storage = multer.memoryStorage();
// ✅ Filter hanya image (jpg, jpeg, png, webp)
const fileFilter = (req, file, cb) => {
const allowedTypes = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
if (allowedTypes.includes(file.mimetype)) {
cb(null, true); // lolos
} else {
cb(new Error("Hanya file gambar yang diperbolehkan (jpg, jpeg, png, webp)"), false);
}
};
const upload = multer({
storage,
fileFilter,
limits: {
fileSize: 100 * 1024 * 1024,
},
});
module.exports = upload;