shell bypass 403
const express = require("express")
const VideoSong = require('../schema/VideoSong')
const Album = require("../schema/Album")
const router = express.Router()
router.post('/new', async (req, res) => {
try {
const { thumbnail, title, album, artist, videoId, tags } = req.body
var videoSong
if (album) {
videoSong = await VideoSong.create({ thumbnail, title, album, artist, videoId, tags })
} else {
videoSong = await VideoSong.create({ thumbnail, title, artist, tags, videoId })
}
if (album) {
const albumObj = await Album.findById(album)
if (!albumObj.songs) {
albumObj.songs = [videoSong._id]
} else {
albumObj.songs.push(videoSong._id)
}
await albumObj.save()
}
if (videoSong) {
return res.json({
success: true,
videoSong
})
}
return res.json({
success: false,
error: 'Something Went Wrong'
})
} catch (error) {
return res.json({
success: false,
error: error.message
})
}
})
router.post('/update', async (req, res) => {
try {
const { id, thumbnail, title, album, releaseDate, artist, file, tags } = req.body
const videoSong = await VideoSong.findById(id)
if (videoSong) {
videoSong.thumbnail = thumbnail
videoSong.title = title
videoSong.album = album
videoSong.artist = artist
videoSong.videoId = videoId
videoSong.tags = tags
await videoSong.save()
return res.json({
success: true,
album
})
}
return res.json({
success: false,
error: 'Something Went Wrong'
})
} catch (error) {
return res.json({
success: false,
error: error.message
})
}
})
router.post('/fetch', async (req, res) => {
try {
// const { page } = req.query
const videoSongs = await VideoSong.find().populate('artist').populate('album')
// .populate('comment').populate('likes')
if (videoSongs) {
return res.json({
success: true,
videoSongs
})
}
return res.json({
success: false,
error: 'Something Went Wrong'
})
} catch (error) {
return res.json({
success: false,
error: error.message
})
}
})
router.post('/fetchbyartist', async (req, res) => {
try {
const { artist } = req.body
console.log('artist',artist)
const videoSongs = await VideoSong.find({artist}).populate('artist').populate('album')
// .populate('comment').populate('likes')
if (videoSongs) {
return res.json({
success: true,
videoSongs
})
}
return res.json({
success: false,
error: 'Something Went Wrong'
})
} catch (error) {
return res.json({
success: false,
error: error.message
})
}
})
router.post('/delete', async (req, res) => {
try {
const { id } = req.body
const videoSong = await VideoSong.findByIdAndDelete(id)
console.log('videoSong', videoSong)
if (videoSong) {
return res.json({
success: true
})
}
return res.json({
success: false,
error: 'Something Went Wrong'
})
} catch (error) {
return res.json({
success: false,
error: error.message
})
}
})
module.exports = router