Initial commit: Club DynaSQY
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user