32 lines
1 KiB
JavaScript
Executable file
32 lines
1 KiB
JavaScript
Executable file
import express from 'express';
|
|
import multer from 'multer';
|
|
import { addMatch, deleteMatch } from '../controllers/adminController.js'; // Assuming this controller file/function
|
|
import { checkPassword, setPassword, verifyPassword } from '../controllers/authController.js';
|
|
|
|
const router = express.Router();
|
|
|
|
// Set up multer for file uploads
|
|
const storage = multer.diskStorage({
|
|
destination: function (req, file, cb) {
|
|
cb(null, './public/uploads/'); // Directory for uploaded files
|
|
},
|
|
filename: function (req, file, cb) {
|
|
cb(null, `${Date.now()}-${file.originalname}`);
|
|
}
|
|
});
|
|
const upload = multer({ storage: storage });
|
|
|
|
// Admin authentication routes
|
|
router.get('/check-password', checkPassword);
|
|
router.post('/set-password', setPassword);
|
|
router.post('/verify-password', verifyPassword);
|
|
|
|
// Route to add a new match
|
|
router.post('/matches', upload.array('pdfFiles'), addMatch);
|
|
|
|
// Route to delete a match
|
|
router.delete('/matches/:id', deleteMatch);
|
|
|
|
// Add other admin routes here later (e.g., for status page)
|
|
|
|
export default router;
|