diff --git a/docs/docs/auth/supertokens.md b/docs/docs/auth/supertokens.md index d7d37bd0d740..f8267d095cff 100644 --- a/docs/docs/auth/supertokens.md +++ b/docs/docs/auth/supertokens.md @@ -11,6 +11,13 @@ yarn rw setup auth supertokens ``` This installs all the packages, writes all the files, and makes all the code modifications you need. + +:::info + +You may have noticed that in `api/src/functions/auth.ts` there's an import from `'supertokens-node/framework/awsLambda'`. This is fine, even if your app isn't running in a serverless environment like AWS Lambda. In "serverful" environments, Redwood automatically handles the translation between Fastify's request and reply objects and functions' AWS Lambda signature. + +::: + For a detailed explanation of all the api- and web-side changes that aren't exclusive to SuperTokens, see the top-level [Authentication](../authentication.md) doc. For now, let's focus on SuperTokens's side of things. diff --git a/docs/docs/serverless-functions.md b/docs/docs/serverless-functions.md index fc327a39063e..c0c53fc8a846 100644 --- a/docs/docs/serverless-functions.md +++ b/docs/docs/serverless-functions.md @@ -2,10 +2,19 @@ description: Create, develop, and run serverless functions --- -# Serverless Functions +# Serverless Functions (API Endpoints) + +:::info + +You can think of serverless functions as API Endpoints, and in the future we'll update the terminology used. + +Originally, Redwood apps were intended to be deployed as serverless functions to AWS Lambda. Whenever a Redwood app is deployed to a "serverful" environment such as Fly or Render, a Fastify server is started and your Redwood app's functions in `api/src/functions` are automatically registered onto the server. Request adapters are also automatically configured to handle the translation between Fastify's request and reply objects to the functions' AWS Lambda signature. + +::: + Redwood looks for serverless functions in `api/src/functions`. Each function is mapped to a URI based on its filename. For example, you can find `api/src/functions/graphql.js` at `http://localhost:8911/graphql`. ## Creating Serverless Functions @@ -34,12 +43,6 @@ export const handler = async (event, context) => { } ``` -:::info - -We call them 'serverless' but they can also be used on 'serverful' hosted environments too, such as Render or Heroku. - -::: - ## The handler For a lambda function to be a lambda function, it must export a handler that returns a status code. The handler receives two arguments: `event` and `context`. Whatever it returns is the `response`, which should include a `statusCode` at the very least.