Skip to content

Commit 77e1ff1

Browse files
committed
Merge branch 'main' of github.com:Intevel/nuxt-directus
2 parents 19610b2 + 3cc1332 commit 77e1ff1

File tree

10 files changed

+381
-204
lines changed

10 files changed

+381
-204
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## v5.4.3
6+
7+
8+
### 🩹 Fixes
9+
10+
- UseRoute is undefined (1c95841)
11+
12+
### ❤️ Contributors
13+
14+
- Conner Bachmann ([@Intevel](http://github.com/Intevel))
15+
16+
## v5.4.2
17+
18+
19+
### 🩹 Fixes
20+
21+
- Invalid url parsing (b7cba7a)
22+
- UseDirectusUrl is not defined (3001e9b)
23+
24+
### ❤️ Contributors
25+
26+
- Conner Bachmann ([@Intevel](http://github.com/Intevel))
27+
528
## v5.4.1
629

730

Lines changed: 80 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,80 @@
1-
# Options
2-
3-
Configure Nuxt Directus easily with the `directus` property.
4-
5-
---
6-
7-
```ts [nuxt.config]
8-
export default {
9-
// Defaults options
10-
directus: {
11-
autoFetch: true,
12-
}
13-
}
14-
```
15-
16-
## `url`
17-
18-
- No default - **Required**
19-
20-
The url to which requests are made to.
21-
22-
## `autoFetch`
23-
24-
- Default: `true`
25-
26-
Should the user be fetched automatically
27-
28-
## `fetchUserParams`
29-
30-
- No default - **Optional**
31-
32-
The Parameters which should be sent when the user is fetched, see [DirectusQueryParams](https://github.com/directus-community/nuxt-directus/blob/313a5a227e1d8b88a43d92c79b47a87d92a21fc5/src/runtime/types/index.d.ts#L26)
33-
34-
## `token`
35-
36-
- No default - **Optional**
37-
38-
A static token
39-
40-
## `cookieNameToken`
41-
42-
- Default: `directus_token`
43-
44-
Specify the cookie name of the directus auth token
45-
46-
## `cookieNameRefreshToken`
47-
48-
- Default: `directus_refresh_token`
49-
50-
Specify the cookie name of the directus refresh auth token
51-
52-
## `devtools`
53-
54-
- Default: `false`
55-
56-
Activate the Nuxt Devtools, checkout [Devtools](/getting-started/devtools) before activating
57-
58-
::feedback-box
59-
::
1+
# Options
2+
3+
Configure Nuxt Directus easily with the `directus` property.
4+
5+
---
6+
7+
```ts [nuxt.config]
8+
export default {
9+
// Defaults options
10+
directus: {
11+
autoFetch: true,
12+
}
13+
}
14+
```
15+
16+
## `url`
17+
18+
- No default - **Required**
19+
20+
The url to which requests are made to.
21+
22+
## `autoFetch`
23+
24+
- Default: `true`
25+
26+
Should the user be fetched automatically
27+
28+
## `autoRefresh`
29+
30+
- Default: `true`
31+
32+
Auto refesh tokens
33+
34+
35+
## `onAutoRefreshFailure()`
36+
37+
- Default: `not defined`
38+
39+
The function that get called if the `autoRefresh` fail
40+
41+
## `maxAgeRefreshToken`
42+
43+
- Default: `604800`
44+
45+
Need to be the same as specified in your directus config; this is the max amount of milliseconds that your refresh cookie will be kept in the browser.
46+
47+
Auto refesh tokens
48+
49+
## `fetchUserParams`
50+
51+
- No default - **Optional**
52+
53+
The Parameters which should be sent when the user is fetched, see [DirectusQueryParams](https://github.com/directus-community/nuxt-directus/blob/313a5a227e1d8b88a43d92c79b47a87d92a21fc5/src/runtime/types/index.d.ts#L26)
54+
55+
## `token`
56+
57+
- No default - **Optional**
58+
59+
A static token
60+
61+
## `cookieNameToken`
62+
63+
- Default: `directus_token`
64+
65+
Specify the cookie name of the directus auth token
66+
67+
## `cookieNameRefreshToken`
68+
69+
- Default: `directus_refresh_token`
70+
71+
Specify the cookie name of the directus refresh auth token
72+
73+
## `devtools`
74+
75+
- Default: `false`
76+
77+
Activate the Nuxt Devtools, checkout [Devtools](/getting-started/devtools) before activating
78+
79+
::feedback-box
80+
::

docs/content/2.composables/1.useDirectusAuth.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,7 @@ const onSubmit = async () => {
104104

105105
## Middleware example
106106

107-
### Redirect user to login
108-
109-
You can protect your authenticated routes by creating a custom middleware in your project, here is an example:
110-
111-
Create `./middleware/auth.ts`
112-
113-
```ts
114-
export default defineNuxtRouteMiddleware((to, _from) => {
115-
const user = useDirectusUser();
116-
117-
if (!user.value) {
118-
return navigateTo("/login");
119-
}
120-
});
121-
```
122-
123-
Now you can add the middleware to your pages
124-
125-
```ts
126-
<script setup lang="ts">
127-
definePageMeta({
128-
middleware: ["auth"]
129-
})
130-
</script>
131-
```
107+
> Check how to Redirect user to login page [over here](/examples/redirectuserlogin).
132108
133109
::feedback-box
134110
::
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# useAsyncData
2+
3+
---
4+
5+
Using `useAsyncData` composable allows your app to fetch data more efficiently with status control (pending, error) and the refresh function option.
6+
Check [Nuxt 3 documentation](https://nuxt.com/docs/api/composables/use-async-data) for more details on `useAsyncData`
7+
8+
```js
9+
const { getItemById } = useDirectusItems();
10+
11+
const {
12+
data: myCollection,
13+
pending,
14+
error,
15+
refresh,
16+
} = await useAsyncData("myCollection", () =>
17+
getItemById({
18+
collection: myCollection,
19+
id: id,
20+
params: params,
21+
})
22+
);
23+
```
24+
::feedback-box
25+
::
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Redirect user to login
2+
3+
---
4+
5+
You can protect your authenticated routes by creating a custom middleware in your project, here is an example:
6+
7+
Create `./middleware/auth.ts`
8+
9+
```ts
10+
export default defineNuxtRouteMiddleware((to, _from) => {
11+
const user = useDirectusUser();
12+
13+
if (!user.value) {
14+
return navigateTo("/login");
15+
}
16+
});
17+
```
18+
19+
Now you can add the middleware to your pages
20+
21+
```ts
22+
<script setup lang="ts">
23+
definePageMeta({
24+
middleware: ["auth"]
25+
})
26+
</script>
27+
```
28+
29+
::feedback-box
30+
::

docs/content/5.examples/_dir.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title: Examples
2+
icon: heroicons-outline:chat-bubble-left-ellipsis

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuxt-directus",
3-
"version": "5.4.1",
3+
"version": "5.4.3",
44
"license": "MIT",
55
"repository": "https://github.com/intevel/nuxt-directus",
66
"homepage": "https://nuxt-directus.netlify.app/",

0 commit comments

Comments
 (0)