feat(tracks): add public list endpoint

This commit is contained in:
2026-05-25 20:28:23 +07:00
parent e344f704a0
commit a702f1f83c
3 changed files with 22 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import Track from '../models/Track.js';
export const trackController = {
async list(req, res, next) {
try {
const tracks = await Track.find().sort({ createdAt: -1 }).lean();
res.json({ success: true, data: tracks });
} catch (error) {
next(error);
}
},
};
+2
View File
@@ -1,6 +1,7 @@
import { Router } from 'express';
import authRoutes from './auths.js';
import adminRoutes from './admins.js';
import trackRoutes from './tracks.js';
const router = Router();
@@ -16,5 +17,6 @@ router.get('/health', (req, res) => {
router.use('/auth', authRoutes);
router.use('/admin', adminRoutes);
router.use('/tracks', trackRoutes);
export default router;
+8
View File
@@ -0,0 +1,8 @@
import { Router } from 'express';
import { trackController } from '../controllers/trackController.js';
const router = Router();
router.get('/', trackController.list);
export default router;