server/src/routes/auth.js
// All controllers/utility functions here
All controllers/utility functions here
All controllers / utility functions here
async function googleLogin(req, res) {
  const { username, email } = req.body
  let user = await prisma.user.findUnique({
    where: {
      email:email
    }
  })
  if(!user) {
    user = await prisma.user.create({
      data: {
        username,
        email
      }
    })
  }
  const tokenPayload = { id: user.id }
  const token = jwt.sign(tokenPayload, process.env.JWT_SECRET, {
    expiresIn: process.env.JWT_EXPIRE
  })
  res.cookie('token', token, { httpOnly: true})
  res.status(200).send(token)
}
async function googleLogin ( req , res ) { const { username , email } = req . body let user = await prisma . user . findUnique ( { where : { email : email } } ) if ( ! user ) { user = await prisma . user . create ( { data : { username , email } } ) } const tokenPayload = { id : user . id } const token = jwt . sign ( tokenPayload , process . env . JWT_SECRET , { expiresIn : process . env . JWT_EXPIRE } ) res . cookie ( 'token' , token , { httpOnly : true } ) res . status ( 200 ) . send ( token ) }
All controllers/utility functions here
All controllers / utility functions here