const router = require('express').Router()
const nonUser = require('./non-user')
const user = require('./user-only')

router.use((req, res, next) => {
  let loggedIn = false
  if (req.session.user) {
    loggedIn = true
  }
  res.locals = {loggedIn}
  next()
})

router.use('/', nonUser)
router.use('/', user)

module.exports = router

const router = require('express').Router()
const nonUser = require('./non-user')
const user = require('./user-only')

router.use((req, res, next) => {
  let loggedIn = false
  let userId = null
  if (req.session.user) {
    loggedIn = true
    userId = req.session.user.user_id
  }
  res.locals = {loggedIn, userId}
  console.log(res.locals);
  next()
})

router.use('/', nonUser)
router.use('/', user)

module.exports = router

Add user id of logged in user to res.locals
Add user id of logged in user to res.locals
