Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: with-remix-tpep_example #797

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0c618bf
docs: add the Remix demo app for thirdpartyemailpassword with testing.
Mar 4, 2024
2a2ed3e
docs: updated changelog
Mar 6, 2024
6211b66
changed test file extension to pass test examples github check
Mar 6, 2024
acedc3c
test: modified testing script to run cjs files.
Mar 7, 2024
04c1caf
fix: removed unused code as part of cleanup
Mar 7, 2024
885c1a8
fix: fix testing script errors
Mar 7, 2024
4754713
fix: modify test examples script
Mar 7, 2024
e6bc0cc
fix: syntax error in test file
Mar 7, 2024
399437b
changed basic test file extension to commonjs
Mar 7, 2024
21d7c90
Update CHANGELOG.md
mawentowski Mar 7, 2024
25cfae7
Update CHANGELOG.md
mawentowski Mar 7, 2024
2f506cf
Update CHANGELOG.md
mawentowski Mar 7, 2024
db9f55e
fix: used old formatting to reduce size of the diff
Mar 7, 2024
3fb3336
docs: created a more comprehensive readme
Mar 7, 2024
6ccb410
fix: removed doesSessionExiststatement since it is unneeded
Mar 7, 2024
90ff84d
fix: remove console.logs
Mar 7, 2024
68917ce
Update examples/with-remix-thirdpartyemailpassword/package.json
mawentowski Mar 7, 2024
e08081b
removed server file as it is not needed
Mar 7, 2024
0697366
fix: renamed auth ui and api routes to be consistent with remix stand…
Mar 11, 2024
dcfeaad
repurposed NextJs request handler for Remix
Mar 11, 2024
e9f4282
add remix config back
Mar 11, 2024
887cefe
fix: reverting changes to troubleshoot example test error
Mar 11, 2024
84b8448
fix: auth route naming error
Mar 11, 2024
ae53b4f
fix: explicitly define types for key-value
Mar 12, 2024
52c9b57
attempting to use getSession directly as example
Mar 13, 2024
27fe759
fix: getSession
anku255 Mar 13, 2024
96b0c8a
added server-side fetching of session details
Mar 13, 2024
e9236d7
added types for session data used for different purposes
Mar 13, 2024
7f02e20
moved type to types file
Mar 13, 2024
599536f
chore: renamed auth apis request handler and converted types file to …
Mar 13, 2024
1be4e1f
chore: abstracted session utils to aseparate file
Mar 13, 2024
d97c1a6
added missing code to from next JS libray
Mar 14, 2024
e1854f6
added refresh component
Mar 15, 2024
63b88fe
added sessionAuthForRemix component based on NextJS
Mar 15, 2024
eca1798
Merge branch 'try-refresh' into docs/with-remix-tpep_example
Mar 15, 2024
bc24cbc
removed duplicate functionality
Mar 15, 2024
6d76795
chore: mostly cleanup of unneeded comments and types
Mar 15, 2024
8b1575a
added console logging for troubleshooting
Mar 18, 2024
63162cb
removed unneeded import;
Mar 18, 2024
f02c8b4
removed debug function
Mar 18, 2024
e716982
docs: fix how cookies are fetched in with-remix example
porcellus Mar 19, 2024
4a6bc48
fix: changes types and formatting for remix example
DBozhinovski Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- run: npm run build || true
- run: |
(HOST= npm start & bash ../../test/waitForServerStartup.sh) && ( \
(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) \
(echo "=========== Test attempt 1 ===========" && npx mocha --no-config --timeout 80000 test/**/*.{test.js,test.cjs}) || \
(echo "=========== Test attempt 2 ===========" && npx mocha --no-config --timeout 80000 test/**/*.{test.js,test.cjs}) || \
(echo "=========== Test attempt 3 ===========" && npx mocha --no-config --timeout 80000 test/**/*.{test.js,test.cjs}) \
)
- name: The job has failed
if: ${{ failure() }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [unreleased]

## Added

A demo Remix app for the third-party email password recipe to the `examples` folder. Also included is a basic test for the example app

## [0.38.0] - 2024-02-29

## Breaking Changes
Expand Down
84 changes: 84 additions & 0 deletions examples/with-remix-thirdpartyemailpassword/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* This is intended to be a basic starting point for linting in your app.
* It relies on recommended configs out of the box for simplicity, but you can
* and should modify this configuration to best suit your team's needs.
*/

/** @type {import('eslint').Linter.Config} */
module.exports = {

root: true,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
commonjs: true,
es6: true,
},

// Base config
extends: ["eslint:recommended"],

overrides: [
// React
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: ["react", "jsx-a11y"],
extends: [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
],
settings: {
react: {
version: "detect",
},
formComponents: ["Form"],
linkComponents: [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
],
"import/resolver": {
typescript: {},
},
},
},

// Typescript
{
files: ["**/*.{ts,tsx}"],
plugins: ["@typescript-eslint", "import"],
parser: "@typescript-eslint/parser",
settings: {
"import/internal-regex": "^~/",
"import/resolver": {
node: {
extensions: [".ts", ".tsx"],
},
typescript: {
alwaysTryTypes: true,
},
},
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
],
},

// Node
{
files: [".eslintrc.js"],
env: {
node: true,
},
},
],
};
3 changes: 3 additions & 0 deletions examples/with-remix-thirdpartyemailpassword/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.cache
/build
/public/build
91 changes: 91 additions & 0 deletions examples/with-remix-thirdpartyemailpassword/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png)

# SuperTokens ThirdPartyEmailPassword Remix Demo App

This demo app demonstrates how to integrate SuperTokens into a Remix application.

This SuperTokens/Remix integration achieves the following:

- Initializes SuperTokens with frontend and backend configurations
- Creates a frontend route to handle authentication-related tasks
- Integrates the SuperTokens' login UI for secure user authentication
- Protects frontend routes to ensure only authenticated users can access certain areas of the application
- Exposes the SuperTokens authentication APIs used by frontend widgets

## Project structure & Parameters

```txt
📦with-remix-thirdpartyemailpassword
┣ 📂app
┃ ┣ 📂config
┃ ┃ ┣ 📜appInfo.tsx
┃ ┃ ┣ 📜backend.tsx
┃ ┃ ┗ 📜frontend.tsx
┃ ┣ 📂routes
┃ ┃ ┣ 📜_index.tsx
┃ ┃ ┣ 📜api.auth.$.tsx
┃ ┃ ┗ 📜auth.$.tsx
┃ ┣ 📜app.css
┃ ┣ 📜entry.server.tsx
┃ ┗ 📜root.tsx
┣ 📂assets
┃ ┣ 📂fonts
┃ ┣ 📂images
┣ 📂test
┃ ┗ 📜basic.test.cjs
┣ 📜package.json
┣ 📜remix.config.mjs
┗ 📜server.mjs
```

Let's explore the important files:

| Directory/File | Description |
| -------------------- | ----------------------------------------------------------------------------------------------- |
| **app** | Contains configuration files and route files for your application. |
| | **config** |
| | Contains configuration files for your application. |
| | `appInfo.tsx` : Includes information about your application reused throughout the app. |
| | `backend.tsx` : Backend-related configuration, including settings for SuperTokens. |
| | `frontend.tsx` : Frontend configuration, including settings for SuperTokens. |
| | **routes** |
| | Contains route files for your application. |
| | `_index.tsx` : Represents the default route or landing page. |
| | `api.auth.$.tsx` : Handles authentication-related API endpoints. |
| | `auth.$.tsx` : Deals with authentication routes or components using SuperTokens. |
| | `entry.server.tsx` : Entry point for server-side rendering (SSR) setup. |
| | `root.tsx` : Root component of your application. |
| **test** | Contains test files for your application. |
| | `basic.test.cjs` : A basic test file, presumably for testing functionality in your application. |
| **remix.config.mjs** | Remix configuration file containing settings for your Remix application. |
| **server.mjs** | File responsible for server-side functionality. |

## Run application locally

Follow the steps outlined below to run the application locally:

1. Change directory to the **with-remix-thirdpartyemailpassword** folder.

```shell
cd supertokens-auth-react/examples/with-remix-thirdpartyemailpassword
```

2. Run the command below to install the project dependencies:

```shell
npm install
```

3. Run the application with the command below:

```shell
npm run dev
```

## Author

Created with :heart: by the folks at supertokens.com.

## License

This project is licensed under the Apache 2.0 license.
Loading
Loading