diff --git a/README.md b/README.md index f2cdfb34..0e9aed9f 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ## Features - Nuxt 3 ready -- Strapi v3 + v4 compatible +- Strapi v5/v4/v3 compatible - Authentication support - RESTful methods - Handle errors with hooks diff --git a/docs/content/1.index.yml b/docs/content/1.index.yml index 6fbc757c..cbad59f3 100644 --- a/docs/content/1.index.yml +++ b/docs/content/1.index.yml @@ -21,7 +21,7 @@ hero: export default defineNuxtConfig({ modules: ['@nuxtjs/strapi'], strapi: { - version: 'v4', + version: 'v5', prefix: '/api' } }) @@ -32,7 +32,7 @@ features: - title: 'Nuxt 3 Ready' description: 'Leverage our auto-imported [composables](/usage) and our [devtools](/devtools) integration.' icon: 'i-simple-icons-nuxtdotjs' - - title: 'Strapi v3 & v4' + - title: 'Strapi v4/v3/v5' description: 'Works with the different versions of Strapi.' icon: 'i-simple-icons-strapi' - title: 'Authentication' diff --git a/docs/content/2.setup.md b/docs/content/2.setup.md index 2c73febf..d72e385c 100644 --- a/docs/content/2.setup.md +++ b/docs/content/2.setup.md @@ -32,7 +32,7 @@ Defaults: url: process.env.STRAPI_URL || 'http://localhost:1337', prefix: '/api', admin: '/admin', - version: 'v4', + version: 'v5', cookie: {}, cookieName: 'strapi_jwt' } @@ -68,13 +68,13 @@ Specify admin prefix used by your Strapi. ### `prefix` -Prefix of the Strapi server. Only used when version is `v4`. +Prefix of the Strapi server. Not for version `v3`. > Learn how to change the default [API prefix](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/api.html) in your Strapi server. ### `version` -Version of the Strapi server. Can only be `v4` or `v3`. +Version of the Strapi server. Can only be `v5`/`v4`/`v3`. ### `cookie` diff --git a/docs/content/3.usage.md b/docs/content/3.usage.md index 6bdc6ee1..bf234eb3 100644 --- a/docs/content/3.usage.md +++ b/docs/content/3.usage.md @@ -7,12 +7,12 @@ description: Learn how to use strapi module in your Nuxt 3 application. ## `useStrapi` -Depending on which version you have in your [options](/setup#options), you will be using either the v3 or v4 client. +Depending on which version you have in your [options](/setup#options), you will be using either the version you want client. ::callout{icon="i-heroicons-light-bulb"} All examples below are demonstrated with v4 `useStrapi()`. :br :br -Note that v3 exposes the same methods with different options. Check out specific types for [v3](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v3.d.ts) and [v4](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v4.d.ts). +Note that v3 exposes the same methods with different options. Check out specific types for [v5](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v5.ts), [v4](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v4.ts) or [v3](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v3.ts). :: > Learn how to handle Strapi errors globally by using [nuxt hooks](/advanced#errors-handling). diff --git a/docs/content/5.advanced.md b/docs/content/5.advanced.md index 396ba49f..d8c0d872 100644 --- a/docs/content/5.advanced.md +++ b/docs/content/5.advanced.md @@ -72,14 +72,14 @@ definePageMeta({ You can use the nuxt `strapi:error` hook to display a toast for example (the following example assumes that a `$toast` plugin has been injected). -Here are examples for both `v4` and `v3` as the signature between both versions is different. +Here are examples for both `v5`/`v4` and `v3` as the signature between both versions is different. > Learn how to change the version in the [options](/setup#options). -### `v4` +### `v5`/`v4` ```ts [plugins/strapi.client.ts] -import type { Strapi4Error } from '@nuxtjs/strapi' +import type { Strapi4Error, Strapi5Error } from '@nuxtjs/strapi' export default defineNuxtPlugin((nuxt) => { nuxt.hook('strapi:error' as any, (e: Strapi4Error) => { @@ -88,7 +88,7 @@ export default defineNuxtPlugin((nuxt) => { }) ``` -> Check out the [Strapi4Error](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v4.d.ts#L3) type. +> Check out the [Strapi5Error](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v5.ts#L3) or [Strapi4Error](https://github.com/nuxt-modules/strapi/blob/dev/src/runtime/types/v4.ts#L3) type. ### `v3` @@ -123,7 +123,7 @@ By default, when calling `/users/me` route, Strapi only returns the user populat Here is how to override this method for both Strapi v3 and v4 by adding our own custom relation, in this example `restaurants`: -### `v4` +### `v5`/`v4` ```js [src/index.js] module.exports = { @@ -137,7 +137,7 @@ module.exports = { } ``` -> Note that in Strapi v4, you must enable the `restaurants.find` permission in your admin for the Authenticated role to have the data populated. +> Note that in Strapi v4 v5, you must enable the `restaurants.find` permission in your admin for the Authenticated role to have the data populated. ### `v3` diff --git a/src/module.ts b/src/module.ts index 228fdbf4..b075b810 100644 --- a/src/module.ts +++ b/src/module.ts @@ -35,9 +35,9 @@ export interface ModuleOptions { /** * Strapi Version - * @default 'v4' + * @default 'v5' * @type string - * @example 'v3' + * @example 'v4' */ version?: 'v5' | 'v4' | 'v3' @@ -86,7 +86,7 @@ export default defineNuxtModule({ url: process.env.STRAPI_URL || 'http://localhost:1337', prefix: '/api', admin: '/admin', - version: 'v4', + version: 'v5', cookie: {}, auth: {}, cookieName: 'strapi_jwt',