feat: add Album model, artist/search/upload controllers, requireArtist middleware

This commit is contained in:
2026-05-26 07:01:11 +07:00
parent 59e4d86a3b
commit b0c29765a9
14 changed files with 278 additions and 7 deletions
+17
View File
@@ -16,3 +16,20 @@ export const requireAdmin = async (req, res, next) => {
return next(error);
}
};
export const requireArtist = 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 !== 'artist' && user.role !== 'admin')) {
return res.status(403).json({ success: false, message: 'Forbidden' });
}
return next();
} catch (error) {
return next(error);
}
};