AnonSec Shell
Server IP : 162.213.251.212  /  Your IP : 18.219.237.93   [ Reverse IP ]
Web Server : LiteSpeed
System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : allssztx ( 535)
PHP Version : 8.1.31
Disable Function : NONE
Domains : 1 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/allssztx/clarkesmusicservices.com/routes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /home/allssztx/clarkesmusicservices.com/routes/artist.js
const express = require("express")
const Artist = require("../schema/Artist")
const Music = require("../schema/Music")
const VideoSong = require("../schema/VideoSong")
const router = express.Router()

router.post('/new', async (req, res) => {
    try {
        const { firstName, lastName, avatar, tags } = req.body
        const artist = await Artist.create({ firstName, lastName, avatar, tags })
        console.log('artist', artist)
        if (artist) {
            return res.json({
                success: true,
                artist
            })
        }
        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, firstName, lastName, avatar, tags } = req.body
        const artist = await Artist.findById(id)
        if (artist) {
            artist.firstName = firstName
            artist.lastName = lastName
            artist.avatar = avatar
            artist.tags = tags
            await artist.save()
            return res.json({
                success: true,
                artist
            })
        }
        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 artists = await Artist.find()
        console.log('artists', artists)
        if (artists) {
            return res.json({
                success: true,
                artists
            })
        }
        return res.json({
            success: false,
            error: 'Something Went Wrong'
        })
    } catch (error) {
        return res.json({
            success: false,
            error: error.message
        })
    }
})
router.post('/fetch-video-artist', async (req, res) => {
    try {
        // const { page } = req.query
        const videoSongArtist = await VideoSong.find().select('artist');
        const videoArtistId = videoSongArtist.map(item => item.artist.toString())
        console.log('videoArtistId', videoArtistId)
        const artists = await Artist.find({_id: videoArtistId})
        if (artists) {
            return res.json({
                success: true,
                artists
            })
        }
        return res.json({
            success: false,
            error: 'Something Went Wrong'
        })
    } catch (error) {
        return res.json({
            success: false,
            error: error.message
        })
    }
})

router.post('/:id', async (req, res) => {
    try {
        // const { page } = req.query
        const { id } = req.params
        const artist = await Artist.findById(id)
        if (artist) {
            const music = await Music.find({ artist: artist._id }).populate('artist').populate('album')
            const videoSongs = await VideoSong.find({ artist: artist._id }).populate('artist').populate('album')
            return res.json({
                success: true,
                artist,
                music,
                videoSongs
            })
        }
        // const artists = await Artist.find()
        // console.log('artists', artists)
        // if (artists) {
        //     return res.json({
        //         success: true,
        //         artists
        //     })
        // }
        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 artists = await Artist.findByIdAndDelete(id)
        console.log('artists', artists)
        if (artists) {
            return res.json({
                success: true
            })
        }
        return res.json({
            success: false,
            error: 'Something Went Wrong'
        })
    } catch (error) {
        return res.json({
            success: false,
            error: error.message
        })
    }
})

router.post('/search', async (req, res) => {
    try {
        const { searchQuery } = req.body
        const artists = await Artist.find({
            $or: [
                { firstName: { $regex: searchQuery, $options: "i" } },
                { lastName: { $regex: searchQuery, $options: "i" } },
                { tags: { $regex: searchQuery, $options: "i" } },
            ],
        })
        console.log('artists', artists)
        if (artists) {
            return res.json({
                success: true,
                artists
            })
        }
        return res.json({
            success: false,
            error: 'Something Went Wrong'
        })
    } catch (error) {
        return res.json({
            success: false,
            error: error.message
        })
    }
})

module.exports = router

Anon7 - 2022
AnonSec Team