Skip to content

Commit

Permalink
pr#53 from Resilient-Labs/feature/favorite-companies; Issue #18
Browse files Browse the repository at this point in the history
Feature/favorite companies started router and controller for favorite companies #18
  • Loading branch information
ZariaHallager authored Jan 7, 2025
2 parents 69c8c88 + 58bd3a4 commit fb14201
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
32 changes: 23 additions & 9 deletions server/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,29 @@ const userController = {
} catch (error) {
next(error)
}
},
getAllUsers: async (req, res, next) => {
try {
const allUsers = await User.find({})
console.log(allUsers)
} catch (error) {
next(error)
}
},
},
getAllUsers: async (req, res, next) => {
try {
const allUsers = await User.find({});
console.log(allUsers);
} catch (error) {
next(error)
}
},
addFavoriteCompany: async (req, res, next) => {
try {

} catch (error) {
next(error)
}
},
getFavoritesCompanies: async (req, res, next) => {
try {
const favorites = await User.find({ clerkId: req.auth.userId }).select('favoriteCompanies')
} catch (error) {
next(error)
}
}
}

export default userController
6 changes: 4 additions & 2 deletions server/routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import userController from '../controllers/user.js'

const userRouter = express.Router()

userRouter.post('/', userController.addUser)
userRouter.get('/', userController.getAllUsers)
userRouter.post('/', userController.addUser);
userRouter.get('/', userController.getAllUsers);
userRouter.get('/favorites', userController.getFavoritesCompanies)
userRouter.post('/favorites', userController.addFavoriteCompany)

export default userRouter

0 comments on commit fb14201

Please sign in to comment.