check it out: ```import express from "express" im...
# support-questions-legacy
a
check it out:
Copy code
import express from "express"
import serverless from "serverless-http"
import bodyParser from "body-parser"
import supertokens from "supertokens-node"
import Session from "supertokens-node/recipe/session"
import EmailPassword from "supertokens-node/recipe/emailpassword"
import cors from "cors"

const app = express()

app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

supertokens.init({
  supertokens: {
    connectionURI: "https://blah-eu-west-1.aws.supertokens.io:3568",
    apiKey: "blah",
  },
  appInfo: {
    appName: "WorkoutApp",
    apiDomain: "https://blah.execute-api.blah.amazonaws.com",
    apiBasePath: "/dev/auth",
    websiteDomain: "http://localhost:3000",
  },
  recipeList: [EmailPassword.init(), Session.init()],
  isInServerlessEnv: true,
})

app.use(
  cors({
    origin: "http://localhost:3000",
    allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
    credentials: true,
  }),
)

app.use(supertokens.middleware())

app.get(
  "/dev/auth",
  Session.verifySession(),
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  async (req: any, res: any) => {
    console.log("FIRST USE REQ:", req)
    
    const session = req.session
    res.send({
      sessionHandle: session.getHandle(),
      userId: session.getUserId(),
      jwtPayload: session.getJWTPayload(),
      sessionData: await session.getSessionData(),
    })
  },
)

app.use(supertokens.errorHandler())

// eslint-disable-next-line @typescript-eslint/no-explicit-any
// app.use((req: any, res: any) => {
//   console.log("LAST USE REQ:", req)
//   res.send("test")
// })

module.exports.app = app
module.exports.handler = serverless(app)