This repository was archived by the owner on May 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Expose event and context of Netlify Function in Next.js pages and API routes #119
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1e35de0
Netlify function template: Remove requestContext object
FinnWoelm c537545
Expose event + context of Netlify Functions on the req object
FinnWoelm 356046e
Cypress: Test that user can modify callbackWaitsForEmptyEventLoop
FinnWoelm 1ba11f8
README: Explain how to use Netlify Identity with next-on-netlify
FinnWoelm 5fa6c5a
Expose netlifyFunction params as netlifyFunctionParams
FinnWoelm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default async function context(req, res) { | ||
res.json({ req, res }); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const Context = ({ context }) => <pre>{JSON.stringify(context, 2, " ")}</pre>; | ||
|
||
export const getServerSideProps = async (context) => { | ||
return { | ||
props: { | ||
context, | ||
}, | ||
}; | ||
}; | ||
|
||
export default Context; |
17 changes: 17 additions & 0 deletions
17
cypress/fixtures/pages/getServerSideProps/wait-on-empty-event-loop/[wait].js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const WaitForEmptyEventLoop = () => <p>Successfully rendered page!</p>; | ||
|
||
export const getServerSideProps = async ({ params, req }) => { | ||
// Set up long-running process | ||
const timeout = setTimeout(() => {}, 100000); | ||
|
||
// Set behavior of whether to wait for empty event loop | ||
const wait = String(params.wait).toLowerCase() === "true"; | ||
const { context: functionContext } = req.netlifyFunctionParams; | ||
functionContext.callbackWaitsForEmptyEventLoop = wait; | ||
|
||
return { | ||
props: {}, | ||
}; | ||
}; | ||
|
||
export default WaitForEmptyEventLoop; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWESOMEEEE