```import jwt from "jsonwebtoken"; import { Conte...
# orm-help
a
Copy code
import jwt from "jsonwebtoken";

import { Context } from ".";

export const APP_SECRET = "GraphQL-is-awesome";

export function getUserId(context: Context): string {
  const bearerToken = context.request.get("Authorization");

  if (!bearerToken) {
    throw new Error("Not Authenticated");
  }

  const token: string = bearerToken.replace("Bearer", "");

  const userId: string = jwt.verify(token, APP_SECRET) as string;

  return userId;
}
i
This code is quiet familiar, I suppose you are trying graphql+prisma+serverless? If yes, then replace context.request.get("Authorization") with context.event.headers['Authorization']