add eslint, fix bugs found
This commit is contained in:
parent
fc2c3a7114
commit
12558d3384
28 changed files with 1774 additions and 745 deletions
|
@ -1,9 +1,8 @@
|
|||
const verifyAuth = require('../../middlewares/verifyAuth');
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const verifyAuth = require('../../middlewares/verifyAuth')
|
||||
const express = require('express')
|
||||
|
||||
module.exports = ({ db, config }) => {
|
||||
const router = express.Router();
|
||||
const router = express.Router()
|
||||
|
||||
router.use(verifyAuth())
|
||||
|
||||
|
@ -13,7 +12,7 @@ module.exports = ({ db, config }) => {
|
|||
})
|
||||
})
|
||||
|
||||
router.use('/wishlist', require('./wishlist')({ db }));
|
||||
router.use('/wishlist', require('./wishlist')({ db }))
|
||||
|
||||
return router;
|
||||
}
|
||||
return router
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
const verifyAuth = require('../../../middlewares/verifyAuth')
|
||||
const express = require('express')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = ({ db, config }) => {
|
||||
module.exports = ({ db }) => {
|
||||
const router = express.Router()
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
|
@ -19,12 +17,12 @@ module.exports = ({ db, config }) => {
|
|||
if (req.params.direction === 'up') wishlist.reverse()
|
||||
let moveFromIndex
|
||||
wishlist.forEach(wish => {
|
||||
if (wish.id === req.params.id) return moveFromIndex = wishlist.indexOf(wish)
|
||||
if (wish.id === req.params.id) moveFromIndex = wishlist.indexOf(wish)
|
||||
})
|
||||
const moveToIndex = wishlist.findIndex(wish => {
|
||||
return ( wishlist.indexOf(wish) > moveFromIndex && wish.addedBy === req.user._id )
|
||||
return (wishlist.indexOf(wish) > moveFromIndex && wish.addedBy === req.user._id)
|
||||
})
|
||||
if (moveToIndex < 0 || moveToIndex > wishlist.length) return res.send({ error: 'Invalid move '})
|
||||
if (moveToIndex < 0 || moveToIndex > wishlist.length) return res.send({ error: 'Invalid move ' })
|
||||
const original = wishlist[moveToIndex]
|
||||
wishlist[moveToIndex] = wishlist[moveFromIndex]
|
||||
wishlist[moveFromIndex] = original
|
||||
|
@ -39,4 +37,4 @@ module.exports = ({ db, config }) => {
|
|||
})
|
||||
|
||||
return router
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue