Skip to content

Commit

Permalink
Update code to run with latest node (#47)
Browse files Browse the repository at this point in the history
Co-authored-by: Rishabh Poddar <[email protected]>
  • Loading branch information
nkshah2 and rishabhpoddar authored Aug 1, 2023
1 parent 5d49945 commit 1184013
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 716 deletions.
22 changes: 21 additions & 1 deletion testHelpers/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ let customRefreshHeaderValue = "";
let supertokens_node_version = require("supertokens-node/lib/build/version").version;
let Querier = require("supertokens-node/lib/build/querier").Querier;
let NormalisedURLPath = require("supertokens-node/lib/build/normalisedURLPath").default;
let Multitenancy, MultitenancyRaw, multitenancySupported;
try {
MultitenancyRaw = require("supertokens-node/lib/build/recipe/multitenancy/recipe").default;
Multitenancy = require("supertokens-node/lib/build/recipe/multitenancy");
multitenancySupported = true;
} catch {
multitenancySupported = false;
}

let urlencodedParser = bodyParser.urlencoded({ limit: "20mb", extended: true, parameterLimit: 20000 });
let jsonParser = bodyParser.json({ limit: "20mb" });
Expand Down Expand Up @@ -200,7 +208,14 @@ app.use(middleware());

app.post("/login", async (req, res) => {
let userId = req.body.userId;
let session = await Session.createNewSession(req, res, userId);

let session;
if (multitenancySupported) {
session = await Session.createNewSession(req, res, "public", userId);
} else {
session = await Session.createNewSession(req, res, userId);
}

res.send(session.getUserId());
});

Expand All @@ -222,6 +237,11 @@ app.post("/startst", async (req, res) => {
if (enableAntiCsrf !== undefined) {
SuperTokensRaw.reset();
SessionRecipeRaw.reset();

if (multitenancySupported) {
MultitenancyRaw.reset();
}

SuperTokens.init(getConfig(enableAntiCsrf, enableJWT));
}
let pid = await startST();
Expand Down
Loading

0 comments on commit 1184013

Please sign in to comment.