diff --git a/examples/with-aws-lambda/.gitignore b/examples/with-aws-lambda/.gitignore deleted file mode 100644 index 93872bd5b..000000000 --- a/examples/with-aws-lambda/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -node_modules -.pnp -.pnp.js - -# testing -coverage - -# production -build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local -.eslintcache -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/examples/with-aws-lambda/README.md b/examples/with-aws-lambda/README.md new file mode 100644 index 000000000..f52b66f84 --- /dev/null +++ b/examples/with-aws-lambda/README.md @@ -0,0 +1 @@ +Please refer to [this](https://github.com/supertokens/supertokens-node/blob/master/examples/aws/with-emailpassword) example to set up SuperTokens with AWS Lambda. diff --git a/examples/with-aws-lambda/backend/auth.js b/examples/with-aws-lambda/backend/auth.js deleted file mode 100644 index 6aab5480f..000000000 --- a/examples/with-aws-lambda/backend/auth.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -let supertokens = require("supertokens-node"); -let { middleware } = require("supertokens-node/framework/awsLambda"); -let middy = require("@middy/core"); -let cors = require("@middy/http-cors"); -let { getBackendConfig } = require("./config"); - -supertokens.init(getBackendConfig()); - -module.exports.handler = middy(middleware()) - .use( - cors({ - origin: getBackendConfig().appInfo.websiteDomain, - credentials: true, - headers: ["Content-Type", ...supertokens.getAllCORSHeaders()].join(", "), - methods: "OPTIONS,POST,GET,PUT,DELETE", - }) - ) - .onError((request) => { - throw request.error; - }); diff --git a/examples/with-aws-lambda/backend/config.js b/examples/with-aws-lambda/backend/config.js deleted file mode 100644 index d7769225f..000000000 --- a/examples/with-aws-lambda/backend/config.js +++ /dev/null @@ -1,21 +0,0 @@ -let Session = require("supertokens-node/recipe/session"); -let EmailPassword = require("supertokens-node/recipe/emailpassword"); -let Dashboard = require("supertokens-node/recipe/dashboard"); - -module.exports.getBackendConfig = () => { - return { - framework: "awsLambda", - supertokens: { - connectionURI: "https://try.supertokens.com", - }, - appInfo: { - appName: "SuperTokens Demo", - apiDomain: "https://0ktsu4mmb6.execute-api.us-east-1.amazonaws.com", - websiteDomain: "http://localhost:8888", - apiBasePath: "/auth", - apiGatewayPath: "/dev", // use this if you are using AWS API Gateway. The value should be equal to the stage value. i.e. if your stage in API Gateway is prod, this value should be /prod - }, - recipeList: [EmailPassword.init(), Session.init(), Dashboard.init()], - isInServerlessEnv: true, - }; -}; diff --git a/examples/with-aws-lambda/backend/package.json b/examples/with-aws-lambda/backend/package.json deleted file mode 100644 index c2b378d92..000000000 --- a/examples/with-aws-lambda/backend/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-lambda-test", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "@middy/core": "^2.5.1", - "@middy/http-cors": "^2.5.1", - "supertokens-node": "latest" - } -} diff --git a/examples/with-aws-lambda/backend/user.js b/examples/with-aws-lambda/backend/user.js deleted file mode 100644 index 48e66c4ab..000000000 --- a/examples/with-aws-lambda/backend/user.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -let supertokens = require("supertokens-node"); -let { verifySession } = require("supertokens-node/recipe/session/framework/awsLambda"); -let middy = require("@middy/core"); -let cors = require("@middy/http-cors"); -let { getBackendConfig } = require("./config"); - -supertokens.init(getBackendConfig()); - -const handler = async (event, _) => { - return { - statusCode: 200, - headers: { - "content-type": "application/json", - }, - body: JSON.stringify({ - sessionHandle: event.session.getHandle(), - userId: event.session.getUserId(), - accessTokenPayload: event.session.getAccessTokenPayload(), - }), - }; -}; - -module.exports.handler = middy(verifySession(handler)) - .use( - cors({ - origin: getBackendConfig().appInfo.websiteDomain, - credentials: true, - headers: ["Content-Type", ...supertokens.getAllCORSHeaders()].join(", "), - methods: "OPTIONS,POST,GET,PUT,DELETE", - }) - ) - .onError((request) => { - throw request.error; - }); diff --git a/examples/with-aws-lambda/frontend/.env b/examples/with-aws-lambda/frontend/.env deleted file mode 100644 index 7d910f148..000000000 --- a/examples/with-aws-lambda/frontend/.env +++ /dev/null @@ -1 +0,0 @@ -SKIP_PREFLIGHT_CHECK=true \ No newline at end of file diff --git a/examples/with-aws-lambda/frontend/package.json b/examples/with-aws-lambda/frontend/package.json deleted file mode 100644 index 7a6ed4b4f..000000000 --- a/examples/with-aws-lambda/frontend/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "frontend", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "BROWSER=none PORT=8888 react-scripts start" - }, - "author": "", - "license": "ISC", - "dependencies": { - "@testing-library/jest-dom": "^5.11.4", - "@testing-library/react": "^11.1.0", - "@testing-library/user-event": "^12.1.10", - "@types/jest": "^26.0.15", - "@types/node": "^12.0.0", - "@types/react": "^16.9.53", - "@types/react-dom": "^16.9.8", - "axios": "^0.21.1", - "body-parser": "^1.19.0", - "npm-run-all": "^4.1.5", - "react": "^18.0.0", - "react-dom": "^18.0.0", - "react-router-dom": "^6.2.1", - "react-scripts": "^5.0.1", - "supertokens-auth-react": "latest", - "typescript": "^4.0.3", - "web-vitals": "^0.2.4" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } -} diff --git a/examples/with-aws-lambda/frontend/public/_redirects b/examples/with-aws-lambda/frontend/public/_redirects deleted file mode 100644 index 78f7f2067..000000000 --- a/examples/with-aws-lambda/frontend/public/_redirects +++ /dev/null @@ -1 +0,0 @@ -/* /index.html 200 \ No newline at end of file diff --git a/examples/with-aws-lambda/frontend/public/background.svg b/examples/with-aws-lambda/frontend/public/background.svg deleted file mode 100644 index a0309e655..000000000 --- a/examples/with-aws-lambda/frontend/public/background.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/with-aws-lambda/frontend/public/favicon.ico b/examples/with-aws-lambda/frontend/public/favicon.ico deleted file mode 100644 index a11777cc4..000000000 Binary files a/examples/with-aws-lambda/frontend/public/favicon.ico and /dev/null differ diff --git a/examples/with-aws-lambda/frontend/public/index.html b/examples/with-aws-lambda/frontend/public/index.html deleted file mode 100644 index 7e63e6f25..000000000 --- a/examples/with-aws-lambda/frontend/public/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - React App - - - -
- - diff --git a/examples/with-aws-lambda/frontend/public/logo192.png b/examples/with-aws-lambda/frontend/public/logo192.png deleted file mode 100644 index fc44b0a37..000000000 Binary files a/examples/with-aws-lambda/frontend/public/logo192.png and /dev/null differ diff --git a/examples/with-aws-lambda/frontend/public/logo512.png b/examples/with-aws-lambda/frontend/public/logo512.png deleted file mode 100644 index a4e47a654..000000000 Binary files a/examples/with-aws-lambda/frontend/public/logo512.png and /dev/null differ diff --git a/examples/with-aws-lambda/frontend/public/manifest.json b/examples/with-aws-lambda/frontend/public/manifest.json deleted file mode 100644 index f01493ff0..000000000 --- a/examples/with-aws-lambda/frontend/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/examples/with-aws-lambda/frontend/public/robots.txt b/examples/with-aws-lambda/frontend/public/robots.txt deleted file mode 100644 index e9e57dc4d..000000000 --- a/examples/with-aws-lambda/frontend/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/examples/with-aws-lambda/frontend/src/App.css b/examples/with-aws-lambda/frontend/src/App.css deleted file mode 100644 index abce9ccf8..000000000 --- a/examples/with-aws-lambda/frontend/src/App.css +++ /dev/null @@ -1,33 +0,0 @@ -.App { - display: flex; - flex-direction: column; - justify-content: stretch; - width: 100vw; - height: 100vh; - font-family: Rubik; -} - -.fill { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - flex: 1 1 auto; -} - -.footer { - align-self: "flex-end"; -} - -.sessionButton { - padding-left: 13px; - padding-right: 13px; - padding-top: 8px; - padding-bottom: 8px; - background-color: black; - border-radius: 10px; - cursor: pointer; - color: white; - font-weight: bold; - font-size: 17px; -} diff --git a/examples/with-aws-lambda/frontend/src/App.test.tsx b/examples/with-aws-lambda/frontend/src/App.test.tsx deleted file mode 100644 index 9b2f4d07b..000000000 --- a/examples/with-aws-lambda/frontend/src/App.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from "react"; -import { render, screen } from "@testing-library/react"; -import App from "./App"; - -test("renders learn react link", () => { - render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/examples/with-aws-lambda/frontend/src/App.tsx b/examples/with-aws-lambda/frontend/src/App.tsx deleted file mode 100644 index 74df216aa..000000000 --- a/examples/with-aws-lambda/frontend/src/App.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import "./App.css"; -import SuperTokens, { SuperTokensWrapper } from "supertokens-auth-react"; -import { getSuperTokensRoutesForReactRouterDom } from "supertokens-auth-react/ui"; -import EmailPassword from "supertokens-auth-react/recipe/emailpassword"; -import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpassword/prebuiltui"; -import Session, { SessionAuth } from "supertokens-auth-react/recipe/session"; -import Home from "./Home"; -import { Routes, BrowserRouter as Router, Route } from "react-router-dom"; -import Footer from "./Footer"; - -export function getDomain() { - let host = window.location.hostname; - let port = window.location.port; - if (port !== "0" && port !== "80" && port !== "443" && port !== "") { - return host + ":" + port; - } - return host; -} -export function getAPIDomain() { - return "https://0ktsu4mmb6.execute-api.us-east-1.amazonaws.com"; -} - -SuperTokens.init({ - appInfo: { - appName: "SuperTokens Demo App", - apiDomain: getAPIDomain(), - websiteDomain: getDomain(), - apiBasePath: "/auth", - apiGatewayPath: "/dev", - }, - recipeList: [EmailPassword.init(), Session.init()], -}); - -function App() { - return ( - - -
-
- - {getSuperTokensRoutesForReactRouterDom(require("react-router-dom"), [ - EmailPasswordPreBuiltUI, - ])} - - - - } - /> - -
-
-
-
-
-
-
- ); -} - -export default App; diff --git a/examples/with-aws-lambda/frontend/src/Footer/index.tsx b/examples/with-aws-lambda/frontend/src/Footer/index.tsx deleted file mode 100644 index 245f4baa4..000000000 --- a/examples/with-aws-lambda/frontend/src/Footer/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -export default function Footer(): JSX.Element { - return ( -
- React Demo app. Made with ❤️ using supertokens.com -
- ); -} diff --git a/examples/with-aws-lambda/frontend/src/Home/CallAPIView.tsx b/examples/with-aws-lambda/frontend/src/Home/CallAPIView.tsx deleted file mode 100644 index 3586ef2e0..000000000 --- a/examples/with-aws-lambda/frontend/src/Home/CallAPIView.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import axios from "axios"; -import { getAPIDomain } from "../App"; - -export default function CallAPIView() { - async function callAPIClicked() { - // this will also automatically refresh the session if needed - let response = await axios.get(getAPIDomain() + "/dev/user"); - window.alert("Session Information:\n" + JSON.stringify(response.data, null, 2)); - } - - return ( -
- Call API -
- ); -} diff --git a/examples/with-aws-lambda/frontend/src/Home/Logout.tsx b/examples/with-aws-lambda/frontend/src/Home/Logout.tsx deleted file mode 100644 index 8df3d314e..000000000 --- a/examples/with-aws-lambda/frontend/src/Home/Logout.tsx +++ /dev/null @@ -1,30 +0,0 @@ -export default function Logout({ logoutClicked }: { logoutClicked: () => void }) { - return ( -
-
- SIGN OUT -
-
- ); -} diff --git a/examples/with-aws-lambda/frontend/src/Home/SuccessView.tsx b/examples/with-aws-lambda/frontend/src/Home/SuccessView.tsx deleted file mode 100644 index 2f03173d3..000000000 --- a/examples/with-aws-lambda/frontend/src/Home/SuccessView.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import CallAPIView from "./CallAPIView"; - -export default function SuccessView({ userId }: { userId: string }) { - return ( -
- - 🥳🎉 - - Login successful -
-
- Your user ID is -
- {userId} -
-
-
-
- -
-
-
- ------------------------------------ -
-
-
- - ); -} diff --git a/examples/with-aws-lambda/frontend/src/Home/index.tsx b/examples/with-aws-lambda/frontend/src/Home/index.tsx deleted file mode 100644 index 5777e347d..000000000 --- a/examples/with-aws-lambda/frontend/src/Home/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; -import Logout from "./Logout"; -import SuccessView from "./SuccessView"; -import { useSessionContext } from "supertokens-auth-react/recipe/session"; -import { useNavigate } from "react-router-dom"; -import { signOut } from "supertokens-auth-react/recipe/emailpassword"; - -export default function Home() { - const sessionContext = useSessionContext(); - const navigate = useNavigate(); - - async function logoutClicked() { - await signOut(); - navigate("/auth"); - } - - if (sessionContext.loading === true) { - return null; - } - - return ( -
- - -
- ); -} diff --git a/examples/with-aws-lambda/frontend/src/index.css b/examples/with-aws-lambda/frontend/src/index.css deleted file mode 100644 index 04146b5e7..000000000 --- a/examples/with-aws-lambda/frontend/src/index.css +++ /dev/null @@ -1,11 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", - "Droid Sans", "Helvetica Neue", sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; -} diff --git a/examples/with-aws-lambda/frontend/src/index.tsx b/examples/with-aws-lambda/frontend/src/index.tsx deleted file mode 100644 index fbbe35ace..000000000 --- a/examples/with-aws-lambda/frontend/src/index.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import { createRoot } from "react-dom/client"; -import "./index.css"; -import App from "./App"; -import reportWebVitals from "./reportWebVitals"; - -createRoot(document.getElementById("root")).render( - - - -); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); diff --git a/examples/with-aws-lambda/frontend/src/logo.svg b/examples/with-aws-lambda/frontend/src/logo.svg deleted file mode 100644 index 9dfc1c058..000000000 --- a/examples/with-aws-lambda/frontend/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/with-aws-lambda/frontend/src/react-app-env.d.ts b/examples/with-aws-lambda/frontend/src/react-app-env.d.ts deleted file mode 100644 index 6431bc5fc..000000000 --- a/examples/with-aws-lambda/frontend/src/react-app-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/with-aws-lambda/frontend/src/reportWebVitals.ts b/examples/with-aws-lambda/frontend/src/reportWebVitals.ts deleted file mode 100644 index 0677b6701..000000000 --- a/examples/with-aws-lambda/frontend/src/reportWebVitals.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ReportHandler } from "web-vitals"; - -const reportWebVitals = (onPerfEntry?: ReportHandler) => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals; diff --git a/examples/with-aws-lambda/frontend/src/setupTests.ts b/examples/with-aws-lambda/frontend/src/setupTests.ts deleted file mode 100644 index 1dd407a63..000000000 --- a/examples/with-aws-lambda/frontend/src/setupTests.ts +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import "@testing-library/jest-dom"; diff --git a/examples/with-aws-lambda/frontend/tsconfig.json b/examples/with-aws-lambda/frontend/tsconfig.json deleted file mode 100644 index c0555cbc6..000000000 --- a/examples/with-aws-lambda/frontend/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx" - }, - "include": ["src"] -}