Skip to content

Commit

Permalink
Merge branch 'dev' into filter-types
Browse files Browse the repository at this point in the history
  • Loading branch information
XanderD99 committed Feb 24, 2025
2 parents bf601e0 + 03b5af7 commit ae256ed
Show file tree
Hide file tree
Showing 10 changed files with 2,125 additions and 913 deletions.
1 change: 1 addition & 0 deletions docs/content/2.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Defaults:
```ts
{
url: process.env.STRAPI_URL || 'http://localhost:1337',
token: process.env.STRAPI_TOKEN || undefined
prefix: '/api',
admin: '/admin',
version: 'v5',
Expand Down
2 changes: 1 addition & 1 deletion docs/content/4.auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const user = useStrapiUser()
## `useStrapiToken`

This composable is an helper to get the jwt token. It is used internally to get the `strapi_jwt` cookie.
This composable is an helper to get the jwt token. It is used internally to get the `strapi_jwt` cookie. If the latter does not exist, this uses the config variable `token`

```ts
const token = useStrapiToken()
Expand Down
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
},
"dependencies": {
"@iconify-json/heroicons": "^1.2.2",
"@iconify-json/simple-icons": "^1.2.16",
"@iconify-json/simple-icons": "^1.2.26",
"@nuxt/content": "^2.13.4",
"@nuxt/fonts": "^0.10.3",
"@nuxt/ui-pro": "^1.6.0",
"@nuxt/ui-pro": "^1.7.0",
"@nuxtjs/plausible": "^1.2.0",
"nuxt": "^3.14.1592",
"nuxt": "^3.15.4",
"nuxt-og-image": "^3.1.1"
},
"devDependencies": {
"@nuxthq/studio": "^2.2.1",
"typescript": "^5.6.3",
"vue-tsc": "^2.1.10"
"vue-tsc": "^2.2.4"
}
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@
"release": "pnpm lint && standard-version && git push --follow-tags"
},
"dependencies": {
"@nuxt/kit": "^3.14.1592",
"@nuxt/kit": "^3.15.4",
"defu": "^6.1.4",
"graphql": "^16.10.0",
"qs": "^6.13.1",
"qs": "^6.14.0",
"ufo": "^1.5.4"
},
"devDependencies": {
"@nuxt/devtools": "^1.6.4",
"@nuxt/eslint-config": "^0.7.3",
"@nuxt/devtools": "^1.7.0",
"@nuxt/eslint-config": "^0.7.6",
"@nuxt/module-builder": "^0.8.4",
"eslint": "^9.17.0",
"nuxt": "^3.14.1592",
"eslint": "^9.21.0",
"nuxt": "^3.15.4",
"standard-version": "^9.5.0",
"typescript": "^5.6.3",
"vue-tsc": "^2.1.10"
"vue-tsc": "^2.2.4"
},
"publishConfig": {
"access": "public"
Expand Down
2,988 changes: 2,092 additions & 896 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"lockFileMaintenance": {
"enabled": true
},
"ignoreDeps": [
"typescript"
],
"packageRules": [{
"matchDepTypes": ["resolutions"],
"enabled": false
Expand Down
7 changes: 7 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export interface ModuleOptions {
* @type string
*/
url?: string
/**
* Strapi API TOKEN
* @default process.env.STRAPI_TOKEN
* @type string
*/
token?: string

/**
* Strapi Prefix
Expand Down Expand Up @@ -84,6 +90,7 @@ export default defineNuxtModule<ModuleOptions>({
},
defaults: {
url: process.env.STRAPI_URL || 'http://localhost:1337',
token: process.env.STRAPI_TOKEN,
prefix: '/api',
admin: '/admin',
version: 'v5',
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/composables/useStrapiToken.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Ref } from 'vue'
import { ref, type Ref } from 'vue'
import { useCookie, useNuxtApp, useRuntimeConfig } from '#imports'

export const useStrapiToken = (): Ref<string | null> => {
Expand All @@ -12,5 +12,10 @@ export const useStrapiToken = (): Ref<string | null> => {

const cookie = useCookie<string | null>(config.strapi.cookieName, config.strapi.cookie)
nuxt._cookies[config.strapi.cookieName] = cookie

if (!cookie.value && config.strapi.token) {
return ref(config.strapi.token)
}

return cookie
}
4 changes: 2 additions & 2 deletions src/runtime/types/v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export interface Strapi4RequestParams<T> {
locale?: StrapiLocale
}

type Strapi4RequestPopulateParams<T> = Pick<Strapi4RequestParams<T>, 'fields' | 'sort' | 'populate' | 'filters'>
export type Strapi4RequestPopulateParams<T> = Pick<Strapi4RequestParams<T>, 'fields' | 'sort' | 'populate' | 'filters'>

// Unified type for Strapi populate, combining both string paths and nested objects.
type Strapi4RequestPopulateParam<T> =
export type Strapi4RequestPopulateParam<T> =
| '*' // Populate all relations.
| { [K in keyof T]?: // Nested object population.
T[K] extends object
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/types/v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export interface Strapi5RequestParams<T> {
locale?: StrapiLocale | null
}

type Strapi5RequestPopulateParams<T> = Pick<Strapi5RequestParams<T>, 'fields' | 'sort' | 'populate' | 'filters'>
export type Strapi5RequestPopulateParams<T> = Pick<Strapi5RequestParams<T>, 'fields' | 'sort' | 'populate' | 'filters'>

// Unified type for Strapi populate, combining both string paths and nested objects.
type Strapi5RequestPopulateParam<T> =
export type Strapi5RequestPopulateParam<T> =
| '*' // Populate all relations.
| { [K in keyof T]?: // Nested object population.
T[K] extends object
Expand Down

0 comments on commit ae256ed

Please sign in to comment.