const express = require('express');
const router = express.Router();
const { upload } = require('../config/multer');
const { auth } = require('../middleware/auth');
const { ok, err } = require('../helpers/response');

router.post('/', auth(['Admin', 'Editor', 'Ustadz']), upload.single('file'), (req, res) => {
  if (!req.file) return err(res, 'File tidak ditemukan');
  ok(res, { url: `/uploads/${req.file.filename}`, filename: req.file.filename });
});

module.exports = router;
