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);
  }
};

apollo-server-lambda

Production-ready Node.js GraphQL server for AWS Lambda

MIT
Latest version published 8 months ago

Package Health Score

82 / 100
Full package analysis