likes likes

This commit is contained in:
Primakov Alexandr Alexandrovich 2023-10-30 22:46:10 +03:00
parent 9f9b652ced
commit 05c9474921

View File

@ -17,3 +17,28 @@ router.use(bannerRouter)
router.use('/v1/auth', authRouter)
router.use(['/v1/tasks', '/v1/task'], jwtMiddlevare, tasksRouter)
router.use('/v1/drafts', jwtMiddlevare, draftsRouter)
const charLikes = {}
router.get('/likes', (req, res) => {
res.send({
likes: charLikes,
})
})
router.post('/toggle-like', (req, res) => {
const { id, charId } = req.body
if (charLikes[charId]) {
charLikes[charId].likes.push(id)
} else {
charLikes[charId] = { likes: [id] }
}
res.send({
likes: charLikes,
})
})
module.exports = router