How to use the http-errors.Gone function in http-errors

To help you get started, we’ve selected a few http-errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ShieldBattery / ShieldBattery / server / lib / api / sessions.js View on Github external
async function getCurrentSession(ctx, next) {
  if (!ctx.session.userId) throw new httpErrors.Gone('Session expired')
  const userId = ctx.session.userId

  let user
  try {
    user = await users.find(userId)
  } catch (err) {
    ctx.log.error({ err }, 'error finding user')
    throw err
  }

  if (!user) {
    await ctx.regenerateSession()
    throw new httpErrors.Gone('Session expired')
  }

  ctx.body = { user, permissions: ctx.session.permissions }
github fastify / fastify-sensible / lib / httpErrors.js View on Github external
gone: function gone (message) {
    return new createError.Gone(message)
  },