https://supertokens.com/ logo
#general
Title
# general
s

Sun Walker

03/25/2020, 3:10 PM
Hey SuperTokens, I currently have this middleware that runs on every request
Copy code
export const secureRoute = async (req: any, _res: any, next: any) => {
  const { authorization } = req.headers;

  if (!authorization) {
    throw new Unauthorized();
  }
  try {
    const token = authorization.replace('Bearer ', '');
    const payload: any = await verifyAccessToken(token);
    if (!payload) {
      throw new Unauthorized();
    }

    req.currentUserId = payload.sub;

    return next();
  } catch (err) {
    throw createHttpError(401, { err });
  }
};
Is there any way to put supertoken session in this or do I not need this any more?