romixch
12/20/2022, 10:11 PMnkshah2
12/21/2022, 5:05 AMromixch
12/21/2022, 6:40 AMimport SessionNode from 'supertokens-node/recipe/session'
import EmailPasswordNode, { getUserById } from 'supertokens-node/recipe/emailpassword'
import { appInfo } from './appInfo'
import { TypeInput } from 'supertokens-node/types'
import DashboardNode from 'supertokens-node/recipe/dashboard'
export const backendConfig = (): TypeInput => {
const apiKey = 'xxxxxxx'
return {
framework: 'express',
supertokens: {
// These are the connection details of the app you created on supertokens.com
connectionURI: 'https://dev-7083ba917d4511edb03b1f2e451c3d8c-eu-west-1.aws.supertokens.io:3568',
apiKey,
},
appInfo,
recipeList: [
EmailPasswordNode.init(),
SessionNode.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
createNewSession: async (input) => {
let userId = input.userId
const user = await getUserById(userId)
// This goes in the access token, and is availble to read on the frontend.
input.accessTokenPayload = { ...input.accessTokenPayload, email: user?.email }
return originalImplementation.createNewSession(input)
},
}
},
},
}),
DashboardNode.init({ apiKey: 'random' }),
],
isInServerlessEnv: true,
}
}
nkshah2
12/21/2022, 6:41 AMromixch
12/21/2022, 6:43 AMnkshah2
12/21/2022, 6:44 AMromixch
12/21/2022, 6:45 AMnkshah2
12/21/2022, 6:45 AMromixch
12/21/2022, 6:45 AMnkshah2
12/21/2022, 6:45 AM