Files
2026-08-23 09:04:47 +00:00

23 lines
885 B
JavaScript

const { Router } = require('express');
const multer = require('multer');
const path = require('path');
const { list, getById, update, uploadPhoto, create, remove } = require('../controllers/memberController');
const { authenticate, adminOnly } = require('../middleware/auth');
const router = Router();
const storage = multer.diskStorage({
destination: (req, file, cb) => cb(null, 'uploads/'),
filename: (req, file, cb) => cb(null, `user_${req.user.id}_${Date.now()}${path.extname(file.originalname)}`)
});
const upload = multer({ storage });
router.get('/', authenticate, list);
router.get('/:id', authenticate, getById);
router.put('/:id', authenticate, update);
router.post('/upload-photo', authenticate, upload.single('photo'), uploadPhoto);
router.post('/', authenticate, adminOnly, create);
router.delete('/:id', authenticate, adminOnly, remove);
module.exports = router;