diff --git a/docs/versioned_docs/version-5.0/a11y.md b/docs/versioned_docs/version-5.x/a11y.md similarity index 100% rename from docs/versioned_docs/version-5.0/a11y.md rename to docs/versioned_docs/version-5.x/a11y.md diff --git a/docs/versioned_docs/version-5.0/app-configuration-redwood-toml.md b/docs/versioned_docs/version-5.x/app-configuration-redwood-toml.md similarity index 100% rename from docs/versioned_docs/version-5.0/app-configuration-redwood-toml.md rename to docs/versioned_docs/version-5.x/app-configuration-redwood-toml.md diff --git a/docs/versioned_docs/version-5.0/assets-and-files.md b/docs/versioned_docs/version-5.x/assets-and-files.md similarity index 100% rename from docs/versioned_docs/version-5.0/assets-and-files.md rename to docs/versioned_docs/version-5.x/assets-and-files.md diff --git a/docs/versioned_docs/version-5.0/auth/auth0.md b/docs/versioned_docs/version-5.x/auth/auth0.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/auth0.md rename to docs/versioned_docs/version-5.x/auth/auth0.md diff --git a/docs/versioned_docs/version-5.0/auth/azure.md b/docs/versioned_docs/version-5.x/auth/azure.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/azure.md rename to docs/versioned_docs/version-5.x/auth/azure.md diff --git a/docs/versioned_docs/version-5.0/auth/clerk.md b/docs/versioned_docs/version-5.x/auth/clerk.md similarity index 57% rename from docs/versioned_docs/version-5.0/auth/clerk.md rename to docs/versioned_docs/version-5.x/auth/clerk.md index f81dfd2fdfc1..ed71df136f8e 100644 --- a/docs/versioned_docs/version-5.0/auth/clerk.md +++ b/docs/versioned_docs/version-5.x/auth/clerk.md @@ -4,6 +4,16 @@ sidebar_label: Clerk # Clerk Authentication +:::caution Did you set up Clerk a while ago? + +If you set up Clerk a while ago, you may be using a deprecated `authDecoder` that's subject to rate limiting. +This decoder will be removed in the next major. +There's a new decoder you can use right now! +See the [migration guide](https://github.com/redwoodjs/redwood/releases/tag/v5.3.2) for how to upgrade. + +::: + + To get started, run the setup command: ```text @@ -12,7 +22,7 @@ yarn rw setup auth clerk This installs all the packages, writes all the files, and makes all the code modifications you need. For a detailed explanation of all the api- and web-side changes that aren't exclusive to Clerk, see the top-level [Authentication](../authentication.md) doc. -There's one Clerk-specific thing we'll get to, but for now, let's focus on Clerk's side of things. +But for now, let's focus on Clerk's side of things. If you don't have a Clerk account yet, now's the time to make one: navigate to https://clerk.dev, sign up, and create an application. The defaults are good enough to get us going, but feel free to configure things as you wish. @@ -27,9 +37,8 @@ How you get your API keys to production depends on your deploy provider. ::: -We're looking for two API keys. -Head over to the "Developers" section in the nav on the left and click "API Keys". Finally select RedwoodJS in the Framework dropdown in the Quick Copy section. -Do as it says and copy the two keys into your project's `.env` file: +After you create the application, you should be redirected to its dashboard where you should see the RedwoodJS logo. +Click on it and copy the two API keys it shows into your project's `.env` file: ```bash title=".env" CLERK_PUBLISHABLE_KEY="..." @@ -41,7 +50,9 @@ Lastly, in your project's `redwood.toml` file, include `CLERK_PUBLISHABLE_KEY` i ```toml title="redwood.toml" [web] # ... - includeEnvironmentVariables = ["CLERK_PUBLISHABLE_KEY"] + includeEnvironmentVariables = [ + "CLERK_PUBLISHABLE_KEY", + ] ``` That should be enough; now, things should just work. @@ -71,15 +82,28 @@ Clicking sign up should open a sign-up box: After you sign up, you should see `{"isAuthenticated":true}` on the page. -## Deep dive: the `ClerkStatusUpdater` component +## Customizing the session token + +There's not a lot to the default session token. +Besides the standard claims, the only thing it really has is the user's `id`. +Eventually, you'll want to customize it so that you can get back more information from Clerk. +You can do so by navigating to the "Sessions" section in the nav on the left, then clicking on "Edit" in the "Customize session token" box: -At the start of this doc, we said that there's one Clerk-specific thing worth noting. -We'll discuss it here, but feel free to skip this section if you'd like—this is all extracurricular. +![clerk_customize_session_token](https://github.com/redwoodjs/redwood/assets/32992335/6d30c616-b4d2-4b44-971b-8addf3b79e5a) -Clerk is a bit unlike the other auth providers Redwood integrates with in that it puts an instance of its client SDK on the browser's `window` object. -That means we have to wait for it to be ready. -With other providers, we instantiate their client SDK in `web/src/auth.ts`, then pass it to `createAuth`. -Not so with Clerk—instead we use special Clerk components and hooks, like `ClerkLoaded` and `useUser`, to update Redwood's auth context with the client when it's ready. +As long as you're using the `clerkJwtDecoder` +all the properties you add will be available to the `getCurrentUser` function: + +```ts title="api/src/lib/auth.ts" +export const getCurrentUser = async ( + decoded, // 👈 All the claims you add will be available on the `decoded` object + // ... +) => { + decoded.myClaim... + + // ... +} +```` ## Avoiding feature duplication @@ -87,3 +111,11 @@ Redwood's Clerk integration is based on [Clerk's React SDK](https://clerk.dev/do This means that there's some duplication between the features in the SDK and the ones in `@redwoodjs/auth-clerk-web`. For example, the SDK ha a `SignedOut` component that redirects a user away from a private page—very much like wrapping a route with Redwood's `Private` component. We recommend you use Redwood's way of doing things as much as possible since it's much more likely to get along with the rest of the framework. + +## Deep dive: the `ClerkStatusUpdater` component + +With Clerk, there's a bit more going on in the `web/src/auth.tsx` file than other auth providers. +This is because Clerk is a bit unlike the other auth providers Redwood integrates with in that it puts an instance of its client SDK on the browser's `window` object. +That means Redwood has to wait for it to be ready. +With other providers, Redwood instantiates their client SDK in `web/src/auth.ts{x}`, then passes it to `createAuth`. +With Clerk, instead Redwood uses Clerk components and hooks, like `ClerkLoaded` and `useUser`, to update Redwood's auth context with the client when it's ready. diff --git a/docs/versioned_docs/version-5.0/auth/custom.md b/docs/versioned_docs/version-5.x/auth/custom.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/custom.md rename to docs/versioned_docs/version-5.x/auth/custom.md diff --git a/docs/versioned_docs/version-5.0/auth/dbauth.md b/docs/versioned_docs/version-5.x/auth/dbauth.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/dbauth.md rename to docs/versioned_docs/version-5.x/auth/dbauth.md diff --git a/docs/versioned_docs/version-5.0/auth/firebase.md b/docs/versioned_docs/version-5.x/auth/firebase.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/firebase.md rename to docs/versioned_docs/version-5.x/auth/firebase.md diff --git a/docs/versioned_docs/version-5.0/auth/netlify.md b/docs/versioned_docs/version-5.x/auth/netlify.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/netlify.md rename to docs/versioned_docs/version-5.x/auth/netlify.md diff --git a/docs/versioned_docs/version-5.0/auth/supabase.md b/docs/versioned_docs/version-5.x/auth/supabase.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/supabase.md rename to docs/versioned_docs/version-5.x/auth/supabase.md diff --git a/docs/versioned_docs/version-5.0/auth/supertokens.md b/docs/versioned_docs/version-5.x/auth/supertokens.md similarity index 100% rename from docs/versioned_docs/version-5.0/auth/supertokens.md rename to docs/versioned_docs/version-5.x/auth/supertokens.md diff --git a/docs/versioned_docs/version-5.0/authentication.md b/docs/versioned_docs/version-5.x/authentication.md similarity index 100% rename from docs/versioned_docs/version-5.0/authentication.md rename to docs/versioned_docs/version-5.x/authentication.md diff --git a/docs/versioned_docs/version-5.0/builds.md b/docs/versioned_docs/version-5.x/builds.md similarity index 100% rename from docs/versioned_docs/version-5.0/builds.md rename to docs/versioned_docs/version-5.x/builds.md diff --git a/docs/versioned_docs/version-5.0/cells.md b/docs/versioned_docs/version-5.x/cells.md similarity index 100% rename from docs/versioned_docs/version-5.0/cells.md rename to docs/versioned_docs/version-5.x/cells.md diff --git a/docs/versioned_docs/version-5.0/cli-commands.md b/docs/versioned_docs/version-5.x/cli-commands.md similarity index 99% rename from docs/versioned_docs/version-5.0/cli-commands.md rename to docs/versioned_docs/version-5.x/cli-commands.md index 257ac8fa9014..d1d6d3c91acf 100644 --- a/docs/versioned_docs/version-5.0/cli-commands.md +++ b/docs/versioned_docs/version-5.x/cli-commands.md @@ -399,7 +399,7 @@ You can pass any flags to the command and use them within your script: See [this how to](how-to/background-worker.md) for an example of using exec to run a background worker. -## experimental +## experimental (alias exp) Set up and run experimental features. @@ -414,11 +414,6 @@ For more information, including details about specific features, see this Redwoo **Available Experimental Features** View all that can be _set up_: ``` -yarn redwood experimental setup --help -``` - -View all that can be _run_: -``` yarn redwood experimental --help ``` @@ -1462,7 +1457,7 @@ yarn redwood lint ## prisma -Run Prisma CLI with experimental features. +Run Prisma CLI within the context of a Redwood project. ``` yarn redwood prisma @@ -1474,7 +1469,7 @@ Redwood's `prisma` command is a lightweight wrapper around the Prisma CLI. It's > > By lightweight wrapper, we mean that we're handling some flags under the hood for you. > You can use the Prisma CLI directly (`yarn prisma`), but letting Redwood act as a proxy (`yarn redwood prisma`) saves you a lot of keystrokes. -> For example, Redwood adds the `--preview-feature` and `--schema=api/db/schema.prisma` flags automatically. +> For example, Redwood adds the `--schema=api/db/schema.prisma` flags automatically. > > If you want to know exactly what `yarn redwood prisma ` runs, which flags it's passing, etc., it's right at the top: > @@ -1759,6 +1754,8 @@ A `generateGraphiQLHeader` file will be created in your `api/lib` folder and inc yarn redwood setup graphiql ``` +If you're using `dbAuth`, make sure the `-i` id you provided is not logged in from the web app. + | Arguments & Options | Description | | :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------- | | `provider` | Auth provider to configure. Choices are `dbAuth`, `netlify`, and `supabase` | @@ -1860,7 +1857,7 @@ yarn redwood setup deploy | Arguments & Options | Description | | :------------------ | :---------------------------------------------------------------------------------------------------- | -| `provider` | Deploy provider to configure. Choices are `aws-serverless`, `netlify`, `render`, or `vercel` | +| `provider` | Deploy provider to configure. Choices are `baremetal`, `coherence`, `edgio`, `flightcontrol`, `netlify`, `render`, `vercel`, or `aws-serverless [deprecated]`, | | `--database, -d` | Database deployment for Render only [choices: "none", "postgresql", "sqlite"] [default: "postgresql"] | | `--force, -f` | Overwrite existing configuration [default: false] | @@ -1914,7 +1911,7 @@ yarn redwood setup tsconfig ### setup ui -Set up a UI design or style library. Right now the choices are [TailwindCSS](https://tailwindcss.com/), [Chakra UI](https://chakra-ui.com/), [Mantine UI](https://ui.mantine.dev/) and [WindiCSS](https://windicss.org/). +Set up a UI design or style library. Right now the choices are [TailwindCSS](https://tailwindcss.com/), [Chakra UI](https://chakra-ui.com/), [Mantine UI](https://ui.mantine.dev/) and [deprecated] [WindiCSS](https://windicss.org/). ``` yarn rw setup ui @@ -1922,7 +1919,7 @@ yarn rw setup ui | Arguments & Options | Description | | :------------------ | :-------------------------------------------------------------------------------------- | -| `library` | Library to configure. Choices are `chakra-ui`, `tailwindcss`, `mantine`, and `windicss` | +| `library` | Library to configure. Choices are `chakra-ui`, `tailwindcss`, `mantine`, and `windicss [deprecated]` | | `--force, -f` | Overwrite existing configuration | ## storybook diff --git a/docs/versioned_docs/version-5.0/connection-pooling.md b/docs/versioned_docs/version-5.x/connection-pooling.md similarity index 100% rename from docs/versioned_docs/version-5.0/connection-pooling.md rename to docs/versioned_docs/version-5.x/connection-pooling.md diff --git a/docs/versioned_docs/version-5.0/contributing-overview.md b/docs/versioned_docs/version-5.x/contributing-overview.md similarity index 100% rename from docs/versioned_docs/version-5.0/contributing-overview.md rename to docs/versioned_docs/version-5.x/contributing-overview.md diff --git a/docs/versioned_docs/version-5.0/contributing-walkthrough.md b/docs/versioned_docs/version-5.x/contributing-walkthrough.md similarity index 100% rename from docs/versioned_docs/version-5.0/contributing-walkthrough.md rename to docs/versioned_docs/version-5.x/contributing-walkthrough.md diff --git a/docs/versioned_docs/version-5.0/cors.md b/docs/versioned_docs/version-5.x/cors.md similarity index 100% rename from docs/versioned_docs/version-5.0/cors.md rename to docs/versioned_docs/version-5.x/cors.md diff --git a/docs/versioned_docs/version-5.0/custom-web-index.md b/docs/versioned_docs/version-5.x/custom-web-index.md similarity index 100% rename from docs/versioned_docs/version-5.0/custom-web-index.md rename to docs/versioned_docs/version-5.x/custom-web-index.md diff --git a/docs/versioned_docs/version-5.0/data-migrations.md b/docs/versioned_docs/version-5.x/data-migrations.md similarity index 100% rename from docs/versioned_docs/version-5.0/data-migrations.md rename to docs/versioned_docs/version-5.x/data-migrations.md diff --git a/docs/versioned_docs/version-5.0/deploy/baremetal.md b/docs/versioned_docs/version-5.x/deploy/baremetal.md similarity index 100% rename from docs/versioned_docs/version-5.0/deploy/baremetal.md rename to docs/versioned_docs/version-5.x/deploy/baremetal.md diff --git a/docs/versioned_docs/version-5.x/deploy/coherence.md b/docs/versioned_docs/version-5.x/deploy/coherence.md new file mode 100644 index 000000000000..970eaa98fa31 --- /dev/null +++ b/docs/versioned_docs/version-5.x/deploy/coherence.md @@ -0,0 +1,40 @@ +--- +description: Serverful deploys on GCP or AWS via Coherence's full-lifecycle environment automation +--- + +# Deploy to Coherence + +[Coherence](https://www.withcoherence.com/) delivers automated environments across the full software development lifecycle, without requiring you to glue together your own mess of open source tools to get a world-class develper experience for your team. Coherence is focused on serving startups, who are doing mission-critical work. With one simple configuration, Coherence offers: + +- Cloud-hosted development environments, based on VSCode. Similar to Gitpod or GitHub CodeSpaces +- Production-ready CI/CD running in your own GCP/AWS account, including: database migration/seeding/snapshot loading, parallelized tests, container building and docker registry management +- Full-stack branch previews. Vercel/Netlify-like developer experience for arbitrary container apps, including dependencies such as CDN, redis, and database resources +- Staging and production environment management in your AWS/GCP accounts. Production runs in its own cloud account (AWS) or project (GCP). Integrated secrets management across all environment types with a developer-friendly UI + +## Coherence Prerequisites + +To deploy to Coherence, your Redwood project needs to be hosted on GitHub and you must have an [AWS](https://docs.withcoherence.com/docs/overview/aws-deep-dive) or [GCP](https://docs.withcoherence.com/docs/overview/gcp-deep-dive) account. + +## Coherence Deploy + +:::caution Prerender doesn't work with Coherence yet + +You can see its current status and follow updates here on GitHub: https://github.com/redwoodjs/redwood/issues/8333. + +But if you don't use prerender, carry on! + +::: + +If you want to deploy your Redwood project on Coherence, run the setup command: + +``` +yarn rw setup deploy coherence +``` + +The command will inspect your Prisma config to determine if you're using a supported database (at the moment, only `postgres` or `mysql` are supported on Coherence). + +Then follow the [Coherence Redwood deploy docs](https://docs.withcoherence.com/docs/configuration/frameworks#redwood-js) for more information, including if you want to set up: +- a redis server +- database migration/seeding/snapshot loading +- cron jobs or async workers +- object storage using Google Cloud Storage or AWS's S3 diff --git a/docs/versioned_docs/version-5.0/deploy/edgio.md b/docs/versioned_docs/version-5.x/deploy/edgio.md similarity index 100% rename from docs/versioned_docs/version-5.0/deploy/edgio.md rename to docs/versioned_docs/version-5.x/deploy/edgio.md diff --git a/docs/versioned_docs/version-5.0/deploy/flightcontrol.md b/docs/versioned_docs/version-5.x/deploy/flightcontrol.md similarity index 100% rename from docs/versioned_docs/version-5.0/deploy/flightcontrol.md rename to docs/versioned_docs/version-5.x/deploy/flightcontrol.md diff --git a/docs/versioned_docs/version-5.0/deploy/introduction.md b/docs/versioned_docs/version-5.x/deploy/introduction.md similarity index 98% rename from docs/versioned_docs/version-5.0/deploy/introduction.md rename to docs/versioned_docs/version-5.x/deploy/introduction.md index ddddcdf10910..1cbb38e0fcd7 100644 --- a/docs/versioned_docs/version-5.0/deploy/introduction.md +++ b/docs/versioned_docs/version-5.x/deploy/introduction.md @@ -13,6 +13,7 @@ Redwood is designed for both serverless and traditional infrastructure deploymen Currently, these are the officially supported deploy targets: - Baremetal (physical server that you have SSH access to) +- [Coherence](https://www.withcoherence.com/) - [Flightcontrol.dev](https://www.flightcontrol.dev?ref=redwood) - [Edg.io](https://edg.io) - [Netlify.com](https://www.netlify.com/) diff --git a/docs/versioned_docs/version-5.0/deploy/netlify.md b/docs/versioned_docs/version-5.x/deploy/netlify.md similarity index 100% rename from docs/versioned_docs/version-5.0/deploy/netlify.md rename to docs/versioned_docs/version-5.x/deploy/netlify.md diff --git a/docs/versioned_docs/version-5.0/deploy/render.md b/docs/versioned_docs/version-5.x/deploy/render.md similarity index 100% rename from docs/versioned_docs/version-5.0/deploy/render.md rename to docs/versioned_docs/version-5.x/deploy/render.md diff --git a/docs/versioned_docs/version-5.0/deploy/serverless.md b/docs/versioned_docs/version-5.x/deploy/serverless.md similarity index 100% rename from docs/versioned_docs/version-5.0/deploy/serverless.md rename to docs/versioned_docs/version-5.x/deploy/serverless.md diff --git a/docs/versioned_docs/version-5.0/deploy/vercel.md b/docs/versioned_docs/version-5.x/deploy/vercel.md similarity index 100% rename from docs/versioned_docs/version-5.0/deploy/vercel.md rename to docs/versioned_docs/version-5.x/deploy/vercel.md diff --git a/docs/versioned_docs/version-5.0/directives.md b/docs/versioned_docs/version-5.x/directives.md similarity index 100% rename from docs/versioned_docs/version-5.0/directives.md rename to docs/versioned_docs/version-5.x/directives.md diff --git a/docs/versioned_docs/version-5.0/environment-variables.md b/docs/versioned_docs/version-5.x/environment-variables.md similarity index 100% rename from docs/versioned_docs/version-5.0/environment-variables.md rename to docs/versioned_docs/version-5.x/environment-variables.md diff --git a/docs/versioned_docs/version-5.0/forms.md b/docs/versioned_docs/version-5.x/forms.md similarity index 99% rename from docs/versioned_docs/version-5.0/forms.md rename to docs/versioned_docs/version-5.x/forms.md index 75dc6d5023a3..db7b39ce2657 100644 --- a/docs/versioned_docs/version-5.0/forms.md +++ b/docs/versioned_docs/version-5.x/forms.md @@ -165,7 +165,7 @@ All of Redwood's form helpers need the `register` function to do what they do. B ### Using `formMethods` -There's some functions that `useForm` returns that it'd be nice to have access to. +There are some functions that `useForm` returns that it'd be nice to have access to. For example, `useForm` returns a function `reset`, which resets the form's fields. To access it, you have to call `useForm` yourself. But you still need to pass `useForm`'s return to the `` so that Redwood's helpers can register themselves: diff --git a/docs/versioned_docs/version-5.0/graphql.md b/docs/versioned_docs/version-5.x/graphql.md similarity index 100% rename from docs/versioned_docs/version-5.0/graphql.md rename to docs/versioned_docs/version-5.x/graphql.md diff --git a/docs/versioned_docs/version-5.0/how-to/background-worker.md b/docs/versioned_docs/version-5.x/how-to/background-worker.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/background-worker.md rename to docs/versioned_docs/version-5.x/how-to/background-worker.md diff --git a/docs/versioned_docs/version-5.0/how-to/build-dashboards-fast-with-tremor.md b/docs/versioned_docs/version-5.x/how-to/build-dashboards-fast-with-tremor.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/build-dashboards-fast-with-tremor.md rename to docs/versioned_docs/version-5.x/how-to/build-dashboards-fast-with-tremor.md diff --git a/docs/versioned_docs/version-5.0/how-to/custom-function.md b/docs/versioned_docs/version-5.x/how-to/custom-function.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/custom-function.md rename to docs/versioned_docs/version-5.x/how-to/custom-function.md diff --git a/docs/versioned_docs/version-5.0/how-to/dbauth-passwordless.md b/docs/versioned_docs/version-5.x/how-to/dbauth-passwordless.md similarity index 99% rename from docs/versioned_docs/version-5.0/how-to/dbauth-passwordless.md rename to docs/versioned_docs/version-5.x/how-to/dbauth-passwordless.md index 8547e395d1a6..d938e62e20cb 100644 --- a/docs/versioned_docs/version-5.0/how-to/dbauth-passwordless.md +++ b/docs/versioned_docs/version-5.x/how-to/dbauth-passwordless.md @@ -127,7 +127,7 @@ export const schema = gql` deleteUser(id: Int!): User! @requireAuth generateToken(email: String!): userTokenResponse! @skipAuth } -` +``` ### 4. Modify the auth function @@ -620,7 +620,7 @@ You should see the changes and it should look like this! ![image](https://user-images.githubusercontent.com/638764/220204883-800829ab-e037-41e1-a2da-d47923c4d20c.png) -### 7. Updating the routes +### 9. Updating the routes The last thing we need to to do is update the routes to use the new page. ```jsx title="/web/src/Routes.js" diff --git a/docs/versioned_docs/version-5.0/how-to/disable-api-database.md b/docs/versioned_docs/version-5.x/how-to/disable-api-database.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/disable-api-database.md rename to docs/versioned_docs/version-5.x/how-to/disable-api-database.md diff --git a/docs/versioned_docs/version-5.0/how-to/file-uploads.md b/docs/versioned_docs/version-5.x/how-to/file-uploads.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/file-uploads.md rename to docs/versioned_docs/version-5.x/how-to/file-uploads.md diff --git a/docs/versioned_docs/version-5.0/how-to/gotrue-auth.md b/docs/versioned_docs/version-5.x/how-to/gotrue-auth.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/gotrue-auth.md rename to docs/versioned_docs/version-5.x/how-to/gotrue-auth.md diff --git a/docs/versioned_docs/version-5.0/how-to/mocking-graphql-in-storybook.md b/docs/versioned_docs/version-5.x/how-to/mocking-graphql-in-storybook.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/mocking-graphql-in-storybook.md rename to docs/versioned_docs/version-5.x/how-to/mocking-graphql-in-storybook.md diff --git a/docs/versioned_docs/version-5.0/how-to/oauth.md b/docs/versioned_docs/version-5.x/how-to/oauth.md similarity index 94% rename from docs/versioned_docs/version-5.0/how-to/oauth.md rename to docs/versioned_docs/version-5.x/how-to/oauth.md index b3f00cc39e04..986653edc756 100644 --- a/docs/versioned_docs/version-5.0/how-to/oauth.md +++ b/docs/versioned_docs/version-5.x/how-to/oauth.md @@ -1,6 +1,6 @@ # OAuth -If you're using an auth provider like [Auth0](/docs/auth/auth0), OAuth login to third party services (GitHub, Google, Facebook) is usually just a setting you can toggle on in your provider's dashboard. But if you're using [dbAuth](/docs/auth/dbauth) you'll only have username/password login to start. But, adding one or more OAuth clients isn't hard. This recipe will walk you through it from scratch, adding OAuth login via GitHub. +If you're using an auth provider like [Auth0](/docs/auth/auth0) OAuth login to third party services (GitHub, Google, Facebook) is usually just a setting you can toggle on in your provider's dashboard. But if you're using [dbAuth](/docs/auth/dbauth) you'll only have username/password login to start. But, adding one or more OAuth clients isn't hard. This recipe will walk you through it from scratch, adding OAuth login via GitHub. ## Prerequisites @@ -33,7 +33,7 @@ Here's the logic flow we're going to implement: 4. The browser is redirected back to our app, to a new function `/api/src/functions/oauth/oauth.js`. 5. The function fetches the OAuth **access_token** with a call to GitHub, using the **code** that was included with the redirect from GitHub in the previous step. 6. When the **access_token** is received, the function then requests the user data from GitHub via another fetch to GitHub's API. -7. The function then checks our database for a user identified by GitHub's `id`. If no user is found, the `User` record is created using the info from the fetch in the previous step. +7. The function the checks our database whether a user identified by GitHub's `id` already exists. If not, the `User` record is created using the info from the fetch in the previous step. 8. The user data from our own database is used to create the same cookie that dbAuth creates on a successful login. 9. The browser is redirected back to our site, and the user is now logged in. @@ -68,6 +68,7 @@ GITHUB_OAUTH_CLIENT_SECRET=92e8662e9c562aca8356d45562911542d89450e1 We also need to denote what data we want permission to read from GitHub once someone authorizes our app. We'll want the user's public info, and probably their email address. That's only two scopes, and we can add those as another ENV var: + ```bash title=/.env GITHUB_OAUTH_CLIENT_ID=41a08ae238b5aee4121d GITHUB_OAUTH_CLIENT_SECRET=92e8662e9c562aca8356d45562911542d89450e1 @@ -75,7 +76,7 @@ GITHUB_OAUTH_CLIENT_SECRET=92e8662e9c562aca8356d45562911542d89450e1 GITHUB_OAUTH_SCOPES="read:user user:email" ``` -If you wanted access to more GitHub data, you can specify [additional scopes](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps) here and they'll be listed to the user when they go to authorize your app. You can also change this list in the future, but you'll need to log the user out and the next time they click **Login with GitHub** they'll be asked to authorize your app again, with a new list of requested scopes. +If you wanted access to more GitHub data, you can specify additional scopes here and they'll be listed to the user when they go to authorize your app. You can also change this list in the future, but you'll need to log the user out and the next time they click **Login with GitHub** they'll be asked to authorize your app again, with a new list of requested scopes. One more ENV var, this is the same callback URL we told GitHub about. This is used in the link in the **Login with GitHub** button and gives GitHub another chance to verify that you're who you say you are: you're proving that you know where you're supposed to redirect back to: @@ -165,7 +166,7 @@ Now let's start filling out this function with the code we need to get the `acce ### Fetching the `access_token` -We told GitHub to redirect to `/oauth/callback` which *appears* like it would be a subdirectory, or child route of our `oauth` function, but in reality everything after `/oauth` just gets shoved into an `event.path` variable that we'll need to inspect to make sure it has the proper parts (like `/callback`). We can do that in the `hander()`: +We told GitHub to redirect to `/oauth/callback` which *appears* like it would be a subdirectory, or child route of our `oauth` function, but in reality everything after `/oauth` just gets shoved into a `path` variable that we'll need to inspect to make sure it has the proper parts (like `/callback`). We can do that in the `hander()`: ```js title=/api/src/functions/oauth/oauth.js export const handler = async (event, _context) => { @@ -350,13 +351,8 @@ model Identity { We're also storing the `accessToken` and `scope` that we got back from the last time we retrived them from GitHub, as well as a timestamp for the last time the user logged in. Storing the `scope` is useful because if you ever change them, you may want to notify users that have the previous scope definition to re-login so the new scopes can be authorized. -::: caution - -There's no GraphQL SDL tied to the Identity table, so it is not accessible via our API. But, if you ever did create an SDL and service, be sure that `accessToken` is not in the list of fields exposed publicly! - -::: +We'll also need to add an `identities` relation to the `User` model, and make the previously required `hashedPassword` and `salt` fields optional (since users may want to *only* authenticate via GitHub, they'll never get to enter a password): -We'll need to add an `identities` relation to the `User` model, and make the previously required `hashedPassword` and `salt` fields optional (since users may want to *only* authenticate via GitHub, they'll never get to enter a password): ```prisma title=/api/db/schema.prisma model User { @@ -386,9 +382,10 @@ On a successful GitHub OAuth login we'll want to first check and see if a user a Let's add some code that returns the user if found, otherwise it creates the user *and* returns it, so that the rest of our code doesn't have to care. :::info -Be sure to import `db` at the top of the file if you haven't already! +Be to import `db` at the top of the file if you haven't already! ::: + ```js title=/api/src/functions/oauth/oauth.js // highlight-next-line import { db } from 'src/lib/db' @@ -479,6 +476,7 @@ const findOrCreateUser = async (providerUser) => { Let's break that down. + ```js const providerUser = await getProviderUser(access_token) // highlight-next-line @@ -810,7 +808,7 @@ Right now we just copy the user details from GitHub right into our new User obje ### Better Error Handling -Right now if an error occurs in the OAuth flow, the browser just stays on the `/oauth/callback` function and sees a plain text error message. A better experience would be to redirect the user back to the login page, with the error message in a query string variable, something like `http://localhost:8910/login?error=Application+not+authorized` Then in the LoginPage, add a `useParams()` to pull out the query variables, and show a toast message if an error is present: +Right now if an error occurs in the OAuth flow, the browser just stays on the `/oauth/callback` function and sees a plain text error message. A better experience would be to redirect the user back to the login page, with the error message in a query string variable, something like `http://localhost:8910/login?error=Application+not+authorized` Then in the LoginPage, add a `useParams()` to pull out they query variables, and show a toast message if an error is present: ```jsx import { useParams } from '@redwoodjs/router' diff --git a/docs/versioned_docs/version-5.0/how-to/pagination.md b/docs/versioned_docs/version-5.x/how-to/pagination.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/pagination.md rename to docs/versioned_docs/version-5.x/how-to/pagination.md diff --git a/docs/versioned_docs/version-5.0/how-to/role-based-access-control.md b/docs/versioned_docs/version-5.x/how-to/role-based-access-control.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/role-based-access-control.md rename to docs/versioned_docs/version-5.x/how-to/role-based-access-control.md diff --git a/docs/versioned_docs/version-5.0/how-to/self-hosting-redwood.md b/docs/versioned_docs/version-5.x/how-to/self-hosting-redwood.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/self-hosting-redwood.md rename to docs/versioned_docs/version-5.x/how-to/self-hosting-redwood.md diff --git a/docs/versioned_docs/version-5.0/how-to/sending-emails.md b/docs/versioned_docs/version-5.x/how-to/sending-emails.md similarity index 99% rename from docs/versioned_docs/version-5.0/how-to/sending-emails.md rename to docs/versioned_docs/version-5.x/how-to/sending-emails.md index bcb62dda77d8..afeb4580fca5 100644 --- a/docs/versioned_docs/version-5.0/how-to/sending-emails.md +++ b/docs/versioned_docs/version-5.x/how-to/sending-emails.md @@ -373,7 +373,7 @@ export const emailUser = async ({ id }: Prisma.UserWhereUniqueInput) => { await sendTestEmail(user.email) await createAudit({ - input: { user: { connect: { id } }, log: 'Admin sent test email to user' }, + input: { userId: id, log: 'Admin sent test email to user' }, }) // ... diff --git a/docs/versioned_docs/version-5.0/how-to/supabase-auth.md b/docs/versioned_docs/version-5.x/how-to/supabase-auth.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/supabase-auth.md rename to docs/versioned_docs/version-5.x/how-to/supabase-auth.md diff --git a/docs/versioned_docs/version-5.0/how-to/test-in-github-actions.md b/docs/versioned_docs/version-5.x/how-to/test-in-github-actions.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/test-in-github-actions.md rename to docs/versioned_docs/version-5.x/how-to/test-in-github-actions.md diff --git a/docs/versioned_docs/version-5.0/how-to/using-a-third-party-api.md b/docs/versioned_docs/version-5.x/how-to/using-a-third-party-api.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/using-a-third-party-api.md rename to docs/versioned_docs/version-5.x/how-to/using-a-third-party-api.md diff --git a/docs/versioned_docs/version-5.0/how-to/windows-development-setup.md b/docs/versioned_docs/version-5.x/how-to/windows-development-setup.md similarity index 100% rename from docs/versioned_docs/version-5.0/how-to/windows-development-setup.md rename to docs/versioned_docs/version-5.x/how-to/windows-development-setup.md diff --git a/docs/versioned_docs/version-5.0/intro-to-servers.md b/docs/versioned_docs/version-5.x/intro-to-servers.md similarity index 100% rename from docs/versioned_docs/version-5.0/intro-to-servers.md rename to docs/versioned_docs/version-5.x/intro-to-servers.md diff --git a/docs/versioned_docs/version-5.0/introduction.md b/docs/versioned_docs/version-5.x/introduction.md similarity index 100% rename from docs/versioned_docs/version-5.0/introduction.md rename to docs/versioned_docs/version-5.x/introduction.md diff --git a/docs/versioned_docs/version-5.0/local-postgres-setup.md b/docs/versioned_docs/version-5.x/local-postgres-setup.md similarity index 100% rename from docs/versioned_docs/version-5.0/local-postgres-setup.md rename to docs/versioned_docs/version-5.x/local-postgres-setup.md diff --git a/docs/versioned_docs/version-5.0/logger.md b/docs/versioned_docs/version-5.x/logger.md similarity index 100% rename from docs/versioned_docs/version-5.0/logger.md rename to docs/versioned_docs/version-5.x/logger.md diff --git a/docs/versioned_docs/version-5.0/mocking-graphql-requests.md b/docs/versioned_docs/version-5.x/mocking-graphql-requests.md similarity index 100% rename from docs/versioned_docs/version-5.0/mocking-graphql-requests.md rename to docs/versioned_docs/version-5.x/mocking-graphql-requests.md diff --git a/docs/versioned_docs/version-5.0/prerender.md b/docs/versioned_docs/version-5.x/prerender.md similarity index 100% rename from docs/versioned_docs/version-5.0/prerender.md rename to docs/versioned_docs/version-5.x/prerender.md diff --git a/docs/versioned_docs/version-5.0/project-configuration-dev-test-build.mdx b/docs/versioned_docs/version-5.x/project-configuration-dev-test-build.mdx similarity index 98% rename from docs/versioned_docs/version-5.0/project-configuration-dev-test-build.mdx rename to docs/versioned_docs/version-5.x/project-configuration-dev-test-build.mdx index 34cab8f014a5..3b78f9378183 100644 --- a/docs/versioned_docs/version-5.0/project-configuration-dev-test-build.mdx +++ b/docs/versioned_docs/version-5.x/project-configuration-dev-test-build.mdx @@ -116,7 +116,7 @@ Simply run your dev server, then attach the debugger from the "run and debug" pa > **ℹ️ Tip: Can't see the "Attach debugger" configuration?** In VSCode > -> You can grab the latest launch.json from the Redwood template [here](https://github.com/redwoodjs/redwood/blob/main/packages/create-redwood-app/template/.vscode/launch.json). Copy the contents into your project's `.vscode/launch.json` +> You can grab the latest launch.json from the Redwood template [here](https://github.com/redwoodjs/redwood/blob/main/packages/create-redwood-app/templates/ts/.vscode/launch.json). Copy the contents into your project's `.vscode/launch.json` #### Customizing the debug port diff --git a/docs/versioned_docs/version-5.0/quick-start.md b/docs/versioned_docs/version-5.x/quick-start.md similarity index 100% rename from docs/versioned_docs/version-5.0/quick-start.md rename to docs/versioned_docs/version-5.x/quick-start.md diff --git a/docs/versioned_docs/version-5.0/redwoodrecord.md b/docs/versioned_docs/version-5.x/redwoodrecord.md similarity index 100% rename from docs/versioned_docs/version-5.0/redwoodrecord.md rename to docs/versioned_docs/version-5.x/redwoodrecord.md diff --git a/docs/versioned_docs/version-5.0/router.md b/docs/versioned_docs/version-5.x/router.md similarity index 100% rename from docs/versioned_docs/version-5.0/router.md rename to docs/versioned_docs/version-5.x/router.md diff --git a/docs/versioned_docs/version-5.0/schema-relations.md b/docs/versioned_docs/version-5.x/schema-relations.md similarity index 100% rename from docs/versioned_docs/version-5.0/schema-relations.md rename to docs/versioned_docs/version-5.x/schema-relations.md diff --git a/docs/versioned_docs/version-5.0/security.md b/docs/versioned_docs/version-5.x/security.md similarity index 100% rename from docs/versioned_docs/version-5.0/security.md rename to docs/versioned_docs/version-5.x/security.md diff --git a/docs/versioned_docs/version-5.0/seo-head.md b/docs/versioned_docs/version-5.x/seo-head.md similarity index 100% rename from docs/versioned_docs/version-5.0/seo-head.md rename to docs/versioned_docs/version-5.x/seo-head.md diff --git a/docs/versioned_docs/version-5.0/serverless-functions.md b/docs/versioned_docs/version-5.x/serverless-functions.md similarity index 100% rename from docs/versioned_docs/version-5.0/serverless-functions.md rename to docs/versioned_docs/version-5.x/serverless-functions.md diff --git a/docs/versioned_docs/version-5.0/services.md b/docs/versioned_docs/version-5.x/services.md similarity index 99% rename from docs/versioned_docs/version-5.0/services.md rename to docs/versioned_docs/version-5.x/services.md index 473e3f8c97fe..819965176f7b 100644 --- a/docs/versioned_docs/version-5.0/services.md +++ b/docs/versioned_docs/version-5.x/services.md @@ -782,7 +782,7 @@ In our example above you could cache the GraphQL query for the most popular prod As of this writing, Redwood ships with clients for the two most popular cache backends: [Memcached](https://memcached.org/) and [Redis](https://redis.io/). Service caching wraps each of these in an adapter, which makes it easy to add more clients in the future. If you're interested in adding an adapter for your favorite cache client, [open a issue](https://github.com/redwoodjs/redwood/issues) and tell us about it! Instructions for getting started with the code are [below](#creating-your-own-client). -::: info +:::info If you need to access functionality in your cache client that the `cache()` and `cacheFindMany()` functions do not handle, you can always get access to the underlying raw client library and use it however you want: diff --git a/docs/versioned_docs/version-5.0/storybook.md b/docs/versioned_docs/version-5.x/storybook.md similarity index 100% rename from docs/versioned_docs/version-5.0/storybook.md rename to docs/versioned_docs/version-5.x/storybook.md diff --git a/docs/versioned_docs/version-5.0/testing.md b/docs/versioned_docs/version-5.x/testing.md similarity index 100% rename from docs/versioned_docs/version-5.0/testing.md rename to docs/versioned_docs/version-5.x/testing.md diff --git a/docs/versioned_docs/version-5.0/toast-notifications.md b/docs/versioned_docs/version-5.x/toast-notifications.md similarity index 100% rename from docs/versioned_docs/version-5.0/toast-notifications.md rename to docs/versioned_docs/version-5.x/toast-notifications.md diff --git a/docs/versioned_docs/version-5.0/tutorial/afterword.md b/docs/versioned_docs/version-5.x/tutorial/afterword.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/afterword.md rename to docs/versioned_docs/version-5.x/tutorial/afterword.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter1/file-structure.md b/docs/versioned_docs/version-5.x/tutorial/chapter1/file-structure.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter1/file-structure.md rename to docs/versioned_docs/version-5.x/tutorial/chapter1/file-structure.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter1/first-page.md b/docs/versioned_docs/version-5.x/tutorial/chapter1/first-page.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter1/first-page.md rename to docs/versioned_docs/version-5.x/tutorial/chapter1/first-page.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter1/installation.md b/docs/versioned_docs/version-5.x/tutorial/chapter1/installation.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter1/installation.md rename to docs/versioned_docs/version-5.x/tutorial/chapter1/installation.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter1/layouts.md b/docs/versioned_docs/version-5.x/tutorial/chapter1/layouts.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter1/layouts.md rename to docs/versioned_docs/version-5.x/tutorial/chapter1/layouts.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter1/prerequisites.md b/docs/versioned_docs/version-5.x/tutorial/chapter1/prerequisites.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter1/prerequisites.md rename to docs/versioned_docs/version-5.x/tutorial/chapter1/prerequisites.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter1/second-page.md b/docs/versioned_docs/version-5.x/tutorial/chapter1/second-page.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter1/second-page.md rename to docs/versioned_docs/version-5.x/tutorial/chapter1/second-page.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter2/cells.md b/docs/versioned_docs/version-5.x/tutorial/chapter2/cells.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter2/cells.md rename to docs/versioned_docs/version-5.x/tutorial/chapter2/cells.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter2/getting-dynamic.md b/docs/versioned_docs/version-5.x/tutorial/chapter2/getting-dynamic.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter2/getting-dynamic.md rename to docs/versioned_docs/version-5.x/tutorial/chapter2/getting-dynamic.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter2/routing-params.md b/docs/versioned_docs/version-5.x/tutorial/chapter2/routing-params.md similarity index 99% rename from docs/versioned_docs/version-5.0/tutorial/chapter2/routing-params.md rename to docs/versioned_docs/version-5.x/tutorial/chapter2/routing-params.md index 802bc1eccbca..318c0fa2002a 100644 --- a/docs/versioned_docs/version-5.0/tutorial/chapter2/routing-params.md +++ b/docs/versioned_docs/version-5.x/tutorial/chapter2/routing-params.md @@ -188,7 +188,7 @@ Cool, cool, cool. Now we need to construct a link that has the ID of a post in i When you have your dev server running, the Redwood CLI will watch your project and generate types. You can regenerate these types manually too, by running `yarn rw g types`. -In this case, the path `/article/{id}` doesn't specify the type of `id` - so it defaults to `string` - where as our article id is actually a `number`. We'll tackle this in in the next few sections - so you can ignore the red squiggle for now, and power through! +In this case, the path `/article/{id}` doesn't specify the type of `id` - so it defaults to `string` - where as our article id is actually a `number`. We'll tackle this in the next few sections - so you can ignore the red squiggle for now, and power through! ::: @@ -341,7 +341,7 @@ export const Failure = ({ error }) => ( ) export const Success = ({ article }) => { - return JSON.stringify(article) + return
{JSON.stringify(article)}
} ``` @@ -375,7 +375,7 @@ export const Failure = ({ error }: CellFailureProps) => ( ) export const Success = ({ article }: CellSuccessProps) => { - return JSON.stringify(article) + return
{JSON.stringify(article)}
} ``` diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter2/side-quest.md b/docs/versioned_docs/version-5.x/tutorial/chapter2/side-quest.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter2/side-quest.md rename to docs/versioned_docs/version-5.x/tutorial/chapter2/side-quest.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter3/forms.md b/docs/versioned_docs/version-5.x/tutorial/chapter3/forms.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter3/forms.md rename to docs/versioned_docs/version-5.x/tutorial/chapter3/forms.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter3/saving-data.md b/docs/versioned_docs/version-5.x/tutorial/chapter3/saving-data.md similarity index 99% rename from docs/versioned_docs/version-5.0/tutorial/chapter3/saving-data.md rename to docs/versioned_docs/version-5.x/tutorial/chapter3/saving-data.md index 45a3b28cba30..0dd80e407b73 100644 --- a/docs/versioned_docs/version-5.0/tutorial/chapter3/saving-data.md +++ b/docs/versioned_docs/version-5.x/tutorial/chapter3/saving-data.md @@ -2021,7 +2021,7 @@ export default ContactPage -That's it! [React Hook Form](https://react-hook-form.com/) provides a bunch of [functionality](https://react-hook-form.com/api) that `
` doesn't expose. When you want to get to that functionality you can call `useForm()` yourself, but make sure to pass the returned object (we called it `formMethods`) as a prop to `` so that the validation and other functionality keeps working. +That's it! [React Hook Form](https://react-hook-form.com/) provides a bunch of [functionality](https://react-hook-form.com/docs) that `` doesn't expose. When you want to get to that functionality you can call `useForm()` yourself, but make sure to pass the returned object (we called it `formMethods`) as a prop to `` so that the validation and other functionality keeps working. :::info diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter4/authentication.md b/docs/versioned_docs/version-5.x/tutorial/chapter4/authentication.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter4/authentication.md rename to docs/versioned_docs/version-5.x/tutorial/chapter4/authentication.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter4/deployment.md b/docs/versioned_docs/version-5.x/tutorial/chapter4/deployment.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter4/deployment.md rename to docs/versioned_docs/version-5.x/tutorial/chapter4/deployment.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter5/first-story.md b/docs/versioned_docs/version-5.x/tutorial/chapter5/first-story.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter5/first-story.md rename to docs/versioned_docs/version-5.x/tutorial/chapter5/first-story.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter5/first-test.md b/docs/versioned_docs/version-5.x/tutorial/chapter5/first-test.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter5/first-test.md rename to docs/versioned_docs/version-5.x/tutorial/chapter5/first-test.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter5/storybook.md b/docs/versioned_docs/version-5.x/tutorial/chapter5/storybook.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter5/storybook.md rename to docs/versioned_docs/version-5.x/tutorial/chapter5/storybook.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter5/testing.md b/docs/versioned_docs/version-5.x/tutorial/chapter5/testing.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter5/testing.md rename to docs/versioned_docs/version-5.x/tutorial/chapter5/testing.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter6/comment-form.md b/docs/versioned_docs/version-5.x/tutorial/chapter6/comment-form.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter6/comment-form.md rename to docs/versioned_docs/version-5.x/tutorial/chapter6/comment-form.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter6/comments-schema.md b/docs/versioned_docs/version-5.x/tutorial/chapter6/comments-schema.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter6/comments-schema.md rename to docs/versioned_docs/version-5.x/tutorial/chapter6/comments-schema.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter6/multiple-comments.md b/docs/versioned_docs/version-5.x/tutorial/chapter6/multiple-comments.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter6/multiple-comments.md rename to docs/versioned_docs/version-5.x/tutorial/chapter6/multiple-comments.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter6/the-redwood-way.md b/docs/versioned_docs/version-5.x/tutorial/chapter6/the-redwood-way.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/chapter6/the-redwood-way.md rename to docs/versioned_docs/version-5.x/tutorial/chapter6/the-redwood-way.md diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter7/api-side-currentuser.md b/docs/versioned_docs/version-5.x/tutorial/chapter7/api-side-currentuser.md similarity index 99% rename from docs/versioned_docs/version-5.0/tutorial/chapter7/api-side-currentuser.md rename to docs/versioned_docs/version-5.x/tutorial/chapter7/api-side-currentuser.md index 0807335372e0..6c1432052689 100644 --- a/docs/versioned_docs/version-5.0/tutorial/chapter7/api-side-currentuser.md +++ b/docs/versioned_docs/version-5.x/tutorial/chapter7/api-side-currentuser.md @@ -674,16 +674,13 @@ import { ForbiddenError } from '@redwoodjs/graphql-server' // highlight-start export const updatePost = async ({ id, input }) => { if (await adminPost({ id })) { - return true + return db.post.update({ + data: input, + where: { id }, + }) } else { throw new ForbiddenError("You don't have access to this post") } - // highlight-end - - return db.post.update({ - data: input, - where: { id }, - }) } ``` @@ -693,7 +690,7 @@ This works, but we'll need to do the same thing in `deletePost`. Let's extract t ```javascript // highlight-start -const verifyOwnership = async (id) { +const verifyOwnership = async ({ id }) => { if (await adminPost({ id })) { return true } else { @@ -704,7 +701,7 @@ const verifyOwnership = async (id) { export const updatePost = async ({ id, input }) => { // highlight-next-line - await verifyOwnership(id) + await verifyOwnership({ id }) return db.post.update({ data: input, @@ -720,7 +717,7 @@ import { ForbiddenError } from '@redwoodjs/graphql-server' import { db } from 'src/lib/db' -const validateOwnership = async ({ id }) => { +const verifyOwnership = async ({ id }) => { if (await adminPost({ id })) { return true } else { @@ -745,7 +742,7 @@ export const createPost = ({ input }) => { } export const updatePost = async ({ id, input }) => { - await validateOwnership({ id }) + await verifyOwnership({ id }) return db.post.update({ data: input, @@ -754,7 +751,7 @@ export const updatePost = async ({ id, input }) => { } export const deletePost = async ({ id }) => { - await validateOwnership({ id }) + await verifyOwnership({ id }) return db.post.delete({ where: { id }, diff --git a/docs/versioned_docs/version-5.0/tutorial/chapter7/rbac.md b/docs/versioned_docs/version-5.x/tutorial/chapter7/rbac.md similarity index 99% rename from docs/versioned_docs/version-5.0/tutorial/chapter7/rbac.md rename to docs/versioned_docs/version-5.x/tutorial/chapter7/rbac.md index ad6b0fafe58c..24758a747c7e 100644 --- a/docs/versioned_docs/version-5.0/tutorial/chapter7/rbac.md +++ b/docs/versioned_docs/version-5.x/tutorial/chapter7/rbac.md @@ -1169,7 +1169,7 @@ describe('comments', () => { }) expect(comment.id).toEqual(scenario.comment.jane.id) - const result = await comments({ postId: scenario.comment.jane.id }) + const result = await comments({ postId: scenario.comment.jane.postId }) expect(result.length).toEqual(0) }) @@ -1263,7 +1263,7 @@ describe('comments', () => { }) expect(comment.id).toEqual(scenario.comment.jane.id) - const result = await comments({ postId: scenario.comment.jane.id }) + const result = await comments({ postId: scenario.comment.jane.postId }) expect(result.length).toEqual(0) } ) diff --git a/docs/versioned_docs/version-5.0/tutorial/foreword.md b/docs/versioned_docs/version-5.x/tutorial/foreword.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/foreword.md rename to docs/versioned_docs/version-5.x/tutorial/foreword.md diff --git a/docs/versioned_docs/version-5.0/tutorial/intermission.md b/docs/versioned_docs/version-5.x/tutorial/intermission.md similarity index 100% rename from docs/versioned_docs/version-5.0/tutorial/intermission.md rename to docs/versioned_docs/version-5.x/tutorial/intermission.md diff --git a/docs/versioned_docs/version-5.0/typescript/generated-types.md b/docs/versioned_docs/version-5.x/typescript/generated-types.md similarity index 100% rename from docs/versioned_docs/version-5.0/typescript/generated-types.md rename to docs/versioned_docs/version-5.x/typescript/generated-types.md diff --git a/docs/versioned_docs/version-5.0/typescript/introduction.md b/docs/versioned_docs/version-5.x/typescript/introduction.md similarity index 60% rename from docs/versioned_docs/version-5.0/typescript/introduction.md rename to docs/versioned_docs/version-5.x/typescript/introduction.md index 54c7abe454b9..eb881419fac1 100644 --- a/docs/versioned_docs/version-5.0/typescript/introduction.md +++ b/docs/versioned_docs/version-5.x/typescript/introduction.md @@ -76,3 +76,59 @@ yarn rw type-check ``` This runs `tsc` on your project and ensures that all the necessary generated types are generated first. Checkout the [CLI reference for type-check](cli-commands.md#type-check) + +### Using Alias Paths + +Alias paths are a mechanism that allows you to define custom shortcuts or aliases for import statements in your code. Instead of using relative or absolute paths to import modules or files, you can use these aliases to make your imports cleaner and more concise. + +Redwood comes with a great starting point by aliasing the `src` directory, but you can take this further by configuring your `tsconfig.json` file, your import paths could go from: + +```ts +// this really long path +import { CustomModal } from 'src/components/modules/admin/common/ui/CustomModal' + +// to this nicer one! +import { CustomModal } from '@adminUI/CustomModal' +``` + +Add you custom `@adminUI` alias to your `tsconfig.json` file: + +```json +{ + "compilerOptions": { +... + "paths": { + "src/*": ["./src/*", "../.redwood/types/mirror/api/src/*"], + + "@adminUI/*": [ + "./src/components/modules/admin/common/ui/*", + "../.redwood/types/mirror/web/src/components/modules/admin/common/ui/*" + ], + + "types/*": ["./types/*", "../types/*"], + "@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/api"] + } + } +... +} +``` + +You might have noticed the `"../.redwood/types/mirror/web/src/components/modules/admin/common/ui/*"` path. I'm glad you did! + +When you build your project redwood will create a set of directories or a virtual directory called`.redwood`, [read more about this typescript feature here](https://www.typescriptlang.org/docs/handbook/module-resolution.html#virtual-directories-with-rootdirs). This directory contains types for te Cells, so there is no need for us to specify an index file. + +When you combine those two paths `.src/...` and `./.redwood/...` under an alias you can have shorter and cleaner import paths: + +```ts +// Instead of this 🥵 +import { CustomModal } from 'src/components/modules/admin/common/ui/CustomModal/CustomModal' + +// they could look like this ✨ +import { CustomModal } from '@adminUI/CustomModal' +``` + +#### Some benefits of using alias paths are + +1. **Improved code readability**, by abstracting complex directory hierarchies, and having meaningful names for your imports. +1. **Code maintainability**, aliases allow you to decouple your code from the file structure and more easily move files around, as they are not tied to the longer path. +1. **Reduce boilerplate**, no more `../../src/components/modules/admin/common/ui/` 😮‍💨 diff --git a/docs/versioned_docs/version-5.0/typescript/strict-mode.md b/docs/versioned_docs/version-5.x/typescript/strict-mode.md similarity index 100% rename from docs/versioned_docs/version-5.0/typescript/strict-mode.md rename to docs/versioned_docs/version-5.x/typescript/strict-mode.md diff --git a/docs/versioned_docs/version-5.0/typescript/utility-types.md b/docs/versioned_docs/version-5.x/typescript/utility-types.md similarity index 100% rename from docs/versioned_docs/version-5.0/typescript/utility-types.md rename to docs/versioned_docs/version-5.x/typescript/utility-types.md diff --git a/docs/versioned_docs/version-5.0/webhooks.md b/docs/versioned_docs/version-5.x/webhooks.md similarity index 100% rename from docs/versioned_docs/version-5.0/webhooks.md rename to docs/versioned_docs/version-5.x/webhooks.md diff --git a/docs/versioned_docs/version-5.0/webpack-configuration.md b/docs/versioned_docs/version-5.x/webpack-configuration.md similarity index 100% rename from docs/versioned_docs/version-5.0/webpack-configuration.md rename to docs/versioned_docs/version-5.x/webpack-configuration.md diff --git a/docs/versioned_sidebars/version-5.0-sidebars.json b/docs/versioned_sidebars/version-5.x-sidebars.json similarity index 97% rename from docs/versioned_sidebars/version-5.0-sidebars.json rename to docs/versioned_sidebars/version-5.x-sidebars.json index f322cad20d0d..0375ad36dec2 100644 --- a/docs/versioned_sidebars/version-5.0-sidebars.json +++ b/docs/versioned_sidebars/version-5.x-sidebars.json @@ -153,6 +153,11 @@ "label": "Baremetal", "id": "deploy/baremetal" }, + { + "type": "doc", + "label": "GCP or AWS via Coherence", + "id": "deploy/coherence" + }, { "type": "doc", "label": "AWS via Flightcontrol", diff --git a/docs/versions.json b/docs/versions.json index 1da3ae754117..369cac7b1a7a 100644 --- a/docs/versions.json +++ b/docs/versions.json @@ -1,6 +1,6 @@ [ "6.0", - "5.0", + "5.x", "4.x", "3.x", "2.x",