-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improved edge function compatibility (#702)
* feat: use built-in fetch when available * chore: bump version * feat: make it possible to use our middleware in some unsupported frameworks * feat: add edge function testing (#704) * feat: add netlify.toml to next example * docs(examples): add postinstall script to install root deps in CI deploys * docs(examples): update appinfo to point to the netlify deployment if defined * docs(examples): update appinfo to point to the netlify deployment * docs(examples): update appinfo to point to the netlify deployment * test: update example tests * chore: prettier * test: add edge function test * test: make sure the nextjs test call refresh to check edge compatibility * test: add shebang to utils script * test: save the output of the deployment in case of a failure * test: save the output of the deployment in case of a failure * test: use netlify_site_id secret * test: build before deploying to netlify * test: add TEST_DEPLOYED_VERSION flag to the edge function test gh action * test: check if prod deploy in netlify works * ci: debug netlify deployment * ci: fixing netlify test deployment * ci: fixing netlify test deployment * ci: remove earlier fix to check if test fails in CI * Revert "ci: remove earlier fix to check if test fails in CI" This reverts commit f4aeedd. * feat: move handleCall from nextjs appdir example * fix: getAppDirRequestHandler export * feat: PartialNextRequest should accept string as method * build: ignore new util script when publishing * feat: add verifySession for custom frameworks with a new callback to save the session obj * feat: add export for custom framework verifySession * test: add type checking test for getAppDirRequestHandler and custom framework verifySession * feat: add custom as an option to the framework config * test: add tests for custom framework --------- Co-authored-by: Rishabh Poddar <[email protected]>
- Loading branch information
1 parent
843cf5e
commit 367d41b
Showing
53 changed files
with
1,350 additions
and
170 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
name: "Test edge function compatibility" | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.netlify_auth_token }} | ||
NETLIFY_SITE_ID: ${{ secrets.netlify_site_id }} | ||
TEST_DEPLOYED_VERSION: true | ||
defaults: | ||
run: | ||
working-directory: examples/next/with-emailpassword | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: echo $GITHUB_REF_NAME | ||
- run: npm install git+https://github.com:supertokens/supertokens-node.git#$GITHUB_SHA | ||
- run: npm install | ||
- run: npm install [email protected] [email protected] puppeteer@^11.0.0 isomorphic-fetch@^3.0.0 | ||
- run: netlify deploy --alias 0 --build --json --auth=$NETLIFY_AUTH_TOKEN > deployInfo.json | ||
- run: cat deployInfo.json | ||
- run: | | ||
( \ | ||
(echo "=========== Test attempt 1 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) || \ | ||
(echo "=========== Test attempt 2 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) || \ | ||
(echo "=========== Test attempt 3 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) \ | ||
) | ||
- name: The job has failed | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: screenshots | ||
path: | | ||
./**/*screenshot.jpeg |
This file contains 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 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 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 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 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 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 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 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 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 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 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,4 @@ | ||
[build] | ||
command = "NEXT_PUBLIC_APP_URL=$DEPLOY_URL npm run build" | ||
functions = "netlify/functions" | ||
publish = ".next" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 * from "../../lib/build/framework/custom"; | ||
import * as _default from "../../lib/build/framework/custom"; | ||
export default _default; |
This file contains 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,6 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
exports.__esModule = true; | ||
__export(require("../../lib/build/framework/custom")); |
This file contains 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,109 @@ | ||
// @ts-nocheck | ||
import type { HTTPMethod } from "../../types"; | ||
import { BaseRequest } from "../request"; | ||
import { BaseResponse } from "../response"; | ||
import { SessionContainerInterface } from "../../recipe/session/types"; | ||
declare type RequestInfo = { | ||
url: string; | ||
method: HTTPMethod; | ||
headers: Headers; | ||
cookies: Record<string, string>; | ||
query: Record<string, string>; | ||
getJSONBody: () => Promise<any>; | ||
getFormBody: () => Promise<any>; | ||
setSession?: (session: SessionContainerInterface) => void; | ||
}; | ||
export declare class PreParsedRequest extends BaseRequest { | ||
private request; | ||
private _session?; | ||
get session(): SessionContainerInterface | undefined; | ||
set session(value: SessionContainerInterface | undefined); | ||
constructor(request: RequestInfo); | ||
getFormData: () => Promise<any>; | ||
getKeyValueFromQuery: (key: string) => string | undefined; | ||
getJSONBody: () => Promise<any>; | ||
getMethod: () => HTTPMethod; | ||
getCookieValue: (key: string) => string | undefined; | ||
getHeaderValue: (key: string) => string | undefined; | ||
getOriginalURL: () => string; | ||
} | ||
export declare type CookieInfo = { | ||
key: string; | ||
value: string; | ||
domain: string | undefined; | ||
secure: boolean; | ||
httpOnly: boolean; | ||
expires: number; | ||
path: string; | ||
sameSite: "strict" | "lax" | "none"; | ||
}; | ||
export declare class CollectingResponse extends BaseResponse { | ||
statusCode: number; | ||
readonly headers: Headers; | ||
readonly cookies: CookieInfo[]; | ||
body?: string; | ||
constructor(); | ||
sendHTMLResponse: (html: string) => void; | ||
setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; | ||
removeHeader: (key: string) => void; | ||
setCookie: ( | ||
key: string, | ||
value: string, | ||
domain: string | undefined, | ||
secure: boolean, | ||
httpOnly: boolean, | ||
expires: number, | ||
path: string, | ||
sameSite: "strict" | "lax" | "none" | ||
) => void; | ||
/** | ||
* @param {number} statusCode | ||
*/ | ||
setStatusCode: (statusCode: number) => void; | ||
sendJSONResponse: (content: any) => void; | ||
} | ||
export declare type NextFunction = (err?: any) => void; | ||
export declare const middleware: <OrigReqType = BaseRequest, OrigRespType = BaseResponse>( | ||
wrapRequest?: (req: OrigReqType) => BaseRequest, | ||
wrapResponse?: (req: OrigRespType) => BaseResponse | ||
) => ( | ||
request: OrigReqType, | ||
response: OrigRespType, | ||
next?: NextFunction | undefined | ||
) => Promise< | ||
| { | ||
handled: boolean; | ||
error?: undefined; | ||
} | ||
| { | ||
error: any; | ||
handled?: undefined; | ||
} | ||
>; | ||
export declare const errorHandler: () => ( | ||
err: any, | ||
request: BaseRequest, | ||
response: BaseResponse, | ||
next: NextFunction | ||
) => Promise<void>; | ||
export declare const CustomFrameworkWrapper: { | ||
middleware: <OrigReqType = BaseRequest, OrigRespType = BaseResponse>( | ||
wrapRequest?: (req: OrigReqType) => BaseRequest, | ||
wrapResponse?: (req: OrigRespType) => BaseResponse | ||
) => ( | ||
request: OrigReqType, | ||
response: OrigRespType, | ||
next?: NextFunction | undefined | ||
) => Promise< | ||
| { | ||
handled: boolean; | ||
error?: undefined; | ||
} | ||
| { | ||
error: any; | ||
handled?: undefined; | ||
} | ||
>; | ||
errorHandler: () => (err: any, request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>; | ||
}; | ||
export {}; |
Oops, something went wrong.