Untitled
unknown
plain_text
2 years ago
2.1 kB
19
Indexable
import SuperTokens from "supertokens-node";
import SessionNode from "supertokens-node/recipe/session/index.js";
import ThirdPartyPasswordlessNode from "supertokens-node/recipe/thirdpartypasswordless/index.js";
import type { TypeInput } from "supertokens-node/types";
import { appInfo } from "./appInfo";
import pkg from "supertokens-node";
const { RecipeUserId } = pkg;
export const backendConfig = (): TypeInput => {
return {
supertokens: {
connectionURI: process.env.SUPERTOKENS_CONNECTION_URI || "",
apiKey: process.env.SUPERTOKENS_API_KEY || "",
},
appInfo,
recipeList: [
ThirdPartyPasswordlessNode.init({
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,
thirdPartySignInAndUpPOST: async function (input) {
input.options.res.setStatusCode(201);
input.options.res.sendJSONResponse({
message: "my custom response",
//...
})
return {
status: "OK",
exists: false
}
}
}
},
},
providers: [
{
config: {
thirdPartyId: "google",
clients: [
{
clientId:
"1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
clientSecret: "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",
scope: ["profile", "email"]
},
],
},
},
],
contactMethod: "EMAIL_OR_PHONE",
flowType: "USER_INPUT_CODE_AND_MAGIC_LINK",
}),
SessionNode.init(),
],
isInServerlessEnv: true,
framework: "custom",
};
};
let initialized = false;
export function ensureSuperTokensInit() {
if (!initialized) {
SuperTokens.init(backendConfig());
initialized = true;
}
}Editor is loading...
Leave a Comment