feat(admin): add add-music api

This commit is contained in:
2026-05-25 19:45:22 +07:00
parent 9d7114e2f1
commit 88dcaea7af
12 changed files with 265 additions and 1 deletions
+18
View File
@@ -0,0 +1,18 @@
import User from '../models/User.js';
export const requireAdmin = async (req, res, next) => {
try {
if (!req.userId) {
return res.status(401).json({ success: false, message: 'Unauthorized' });
}
const user = await User.findById(req.userId).select('role').lean();
if (!user || user.role !== 'admin') {
return res.status(403).json({ success: false, message: 'Forbidden' });
}
return next();
} catch (error) {
return next(error);
}
};