/routes/base.coffee

https://github.com/firede/knowledge · CoffeeScript · 7 lines · 6 code · 1 blank · 0 comment · 0 complexity · e14531e5c7f2d768a873ef30ed3c78b3 MD5 · raw file

  1. _ = require 'lodash'
  2. module.exports = (req, res) ->
  3. tagIds = _.pluck(req.app.locals.tags, 'id')
  4. tagIndex = _.random(0, tagIds.length - 1)
  5. tagId = tagIds[tagIndex]
  6. res.redirect "/tag/#{tagId}"