import { apiPrefix } from '../../utility/constants/app';
import { getVideo, getVideos } from '../fetch/videos';
import middlewares from '../helper/middlewares';
import { getVideosWithSelectedAttributes, getVideoWithSelectedAttributes } from '../mapper/lib';
export default async function videosEndpoints(app) {
app.get(`${apiPrefix}/videos/:videoId`, middlewares, async (req, res) => {
const result = await getVideo(req);
const video = getVideoWithSelectedAttributes(result, null);
res.json(video);
});
app.get(`${apiPrefix}/videos`, middlewares, async (req, res) => {
const result = await getVideos(req);
const videos = getVideosWithSelectedAttributes(result, null);
res.json(videos);
});
}