How to use the apollo-server-lambda.AuthenticationError function in apollo-server-lambda

To help you get started, we’ve selected a few apollo-server-lambda 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 tcerdaITBA / Serverless-Graphql-Next.js-boilerplate / api / src / utils / auth.js View on Github external
const getUser = headers => {
  const authorization = headers.authorization || headers.Authorization;

  if (!authorization) {
    throw new AuthenticationError('Missing authorization header');
  }

  const token = authorization.replace('Bearer ', '');

  try {
    return jwt.verify(token, process.env.APP_SECRET);
  } catch (error) {
    throw new AuthenticationError(error.message);
  }
};
github tcerdaITBA / Serverless-Graphql-Next.js-boilerplate / api / src / utils / auth.js View on Github external
const getUser = headers => {
  const authorization = headers.authorization || headers.Authorization;

  if (!authorization) {
    throw new AuthenticationError('Missing authorization header');
  }

  const token = authorization.replace('Bearer ', '');

  try {
    return jwt.verify(token, process.env.APP_SECRET);
  } catch (error) {
    throw new AuthenticationError(error.message);
  }
};