Skip to content

Commit 94db2f4

Browse files
suzdalnitskijtoar
andauthored
docs: added some clarification on serverless functions getting executed in a non-serverless environment (#9742)
Closes #9741. --------- Co-authored-by: Dominic Saadi <[email protected]>
1 parent 751214b commit 94db2f4

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

docs/docs/auth/supertokens.md

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ yarn rw setup auth supertokens
1111
```
1212

1313
This installs all the packages, writes all the files, and makes all the code modifications you need.
14+
15+
:::info
16+
17+
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.
18+
19+
:::
20+
1421
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.
1522
For now, let's focus on SuperTokens's side of things.
1623

docs/docs/serverless-functions.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
description: Create, develop, and run serverless functions
33
---
44

5-
# Serverless Functions
5+
# Serverless Functions (API Endpoints)
66

77
<!-- `redwood.toml`&mdash;`api/src/functions` by default. -->
88

9+
10+
:::info
11+
12+
You can think of serverless functions as API Endpoints, and in the future we'll update the terminology used.
13+
14+
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.
15+
16+
:::
17+
918
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`.
1019

1120
## Creating Serverless Functions
@@ -34,12 +43,6 @@ export const handler = async (event, context) => {
3443
}
3544
```
3645

37-
:::info
38-
39-
We call them 'serverless' but they can also be used on 'serverful' hosted environments too, such as Render or Heroku.
40-
41-
:::
42-
4346
## The handler
4447

4548
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.

0 commit comments

Comments
 (0)