I want to use supertokens with AWS API gateway+lambda functions I tried following the recipe https...
s
I want to use supertokens with AWS API gateway+lambda functions I tried following the recipe https://supertokens.com/docs/emailpassword/serverless/with-aws-lambda/backend-config for the backend config, the tutorial says " Create a config.js file in the root directory of your project. " All I have are bunch of lambda functions called from API gateway. Where do I create these files? 🤔
r
You need to add this config in your JS files which use supertokens functions. So In all the lambda functions that will use supertokens
s
That means along side the index.js which contains the actual lambda function?
r
Yea
s
@rp_st how do you suggest I run "npm install" for supertoken in lambda
r
AWS lambda has a way of doing that - maybe checkout their docs
s
I fixed the import errors. created layers for supertoken, middy/core and middy/http
now i'm getting 2022-09-14T05:40:00.967Z 1373933d-b7fe-407d-935c-4335994d0d3f ERROR Invoke Error { "errorType": "TypeError", "errorMessage": "next is not a function", "trace": [ "TypeError: next is not a function", " at /opt/nodejs/node_modules/supertokens-node/lib/build/framework/express/framework.js:169:25", " at Generator.throw ()", " at rejected (/opt/nodejs/node_modules/supertokens-node/lib/build/framework/express/framework.js:36:44)" ] }
when I call the function
r
the imports are wrong
please check the docs
you are supposed to import from
supertokens-node/framework/awsLambda
as you can see line number (2)'s import
s
Oh yeah my bad
what could I be missing here?
r
s
Ah I was looking at the core one
cool this signup and sign in worked
Can I contribute to the tutorial? Add the bits and pieces that need to be done on aws side?
r
Yea sure! There should be an "edit" button at the bottom of the page. Click on that and create a PR 🙂
8 Views