mirror of
https://github.com/kevin-DL/commander_league_web.git
synced 2026-01-11 18:14:27 +00:00
18 lines
463 B
JavaScript
18 lines
463 B
JavaScript
import { verifyIdToken } from '../../utils/auth/firebaseAdmin'
|
|
const favoriteFoods = ['pizza', 'burger', 'chips', 'tortilla']
|
|
|
|
const getFood = async (req, res) => {
|
|
const token = req.headers.token
|
|
|
|
try {
|
|
await verifyIdToken(token)
|
|
return res.status(200).json({
|
|
food: favoriteFoods[Math.floor(Math.random() * favoriteFoods.length)],
|
|
})
|
|
} catch (error) {
|
|
return res.status(401).send('You are unauthorised')
|
|
}
|
|
}
|
|
|
|
export default getFood
|