@nuxtus/nuxtus 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -12
- package/TODO +9 -1
- package/changelog.md +6 -0
- package/client/package.json +4 -3
- package/client/plugins/{directusLogin.ts → directusLogin.client.ts} +2 -2
- package/client/server/api/directus/collection.post.ts +7 -2
- package/client/server/api/directus/field.post.ts +32 -0
- package/package.json +2 -2
- package/server/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ https://user-images.githubusercontent.com/324026/175452950-46bd51a6-3fd9-441d-80
|
|
|
21
21
|
- [HeroIcons](https://heroicons.com/)
|
|
22
22
|
- [Google Fonts](https://github.com/nuxt-community/google-fonts-module)
|
|
23
23
|
- [Nuxtus CLI](https://github.com/nuxtus/cli)
|
|
24
|
+
- Typescript types
|
|
24
25
|
|
|
25
26
|
## Quickstart (preferred)
|
|
26
27
|
|
|
@@ -63,23 +64,18 @@ $ npm start
|
|
|
63
64
|
|
|
64
65
|
Nuxtus includes a POST endpoint located /api/directus/collection that will run in development. If you used `npx create-nuxtus` to create your Nuxtus project and selected "yes" to automatically creating pages from Directus then this is already configured in Directus for you.
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
Collections are also typed automatically, simply prepend "Items" to the collection name as per below:
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Collections: directus_collections
|
|
73
|
-
|
|
74
|
-
#### Webhook / Request URL
|
|
69
|
+
```typescript
|
|
70
|
+
import { components } from "../interfaces/nuxtus";
|
|
71
|
+
type Test = components["schemas"]["ItemsTest"];
|
|
72
|
+
```
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
Method: POST
|
|
78
|
-
Request Body: `{{$last.payload}}`
|
|
74
|
+
> Because OpenAPI schemas may have invalid TypeScript characters as names, the square brackets are a safe way to access every property.
|
|
79
75
|
|
|
80
76
|
### Manually creating pages
|
|
81
77
|
|
|
82
|
-
Nuxtus includes Nuxtus CLI which will
|
|
78
|
+
Nuxtus includes Nuxtus CLI which will generate listing and view pages of any Directus collection on demand. To use it:
|
|
83
79
|
|
|
84
80
|
1. Log in to Directus ([http://0.0.0.0:8055/admin/login](http://0.0.0.0:8055/admin/login)) and [create a collection](https://docs.directus.io/configuration/data-model/#creating-a-collection)
|
|
85
81
|
2. From the client folder (`cd client`) run `nuxtus create` and follow the prompts
|
|
@@ -100,4 +96,11 @@ Clone this repo onto your local machine, remove the remote git origin and add a
|
|
|
100
96
|
|
|
101
97
|
> For further instructions visit `[http://localhost:3000](http://localhost:3000)`
|
|
102
98
|
|
|
99
|
+
## Acknowledgements
|
|
100
|
+
|
|
101
|
+
Nuxtus wouldn't be possible without the following amazing technologies:
|
|
103
102
|
|
|
103
|
+
[Directus](https://directus.io)
|
|
104
|
+
[Nuxt](https://nuxt.js.org)
|
|
105
|
+
[Nuxt-Directus](https://nuxt-directus.netlify.app/)
|
|
106
|
+
[OpenApi Typescript](https://www.npmjs.com/package/openapi-typescript)
|
package/TODO
CHANGED
|
@@ -13,5 +13,13 @@ Todo:
|
|
|
13
13
|
☐ Documentation: https://docusaurus.io/ or https://vuepress.vuejs.org/
|
|
14
14
|
✔ Create Directus flow via Directus API @done(22-07-04 17:46)
|
|
15
15
|
☐ Add ability to automatically update .env for none SQLite databases
|
|
16
|
-
☐ Can I HMR when adding new pages/routes?
|
|
16
|
+
☐ Can I HMR when adding new pages/routes? - requires Nuxt to fix bug
|
|
17
17
|
☐ Add all questions in create-app to start of process for better user flow
|
|
18
|
+
☐ Allow use of different ports/URLs for Directus and Nuxt (currently hard-coded)
|
|
19
|
+
☐ Add "types" to cli to update types from Directus when not using hook
|
|
20
|
+
☐ Make opening browser window on start optional using npm run start
|
|
21
|
+
☐ Make sure separate packages can be used without Nuxt Boilerplate if required
|
|
22
|
+
☐ Console.log messages from directus extension should be formatted like other directus messages
|
|
23
|
+
☐ When adding a new collection the new page triggers a nuxt restart then directus tries to send a field.create which fails. We get around this by getting the create field first but Directus still returns a 404 for the second request.
|
|
24
|
+
✔ interfaces/nuxtus.ts should not be in .gitignore other than during my development (remove in create-nuxtus?) @done(22-07-11 12:52)
|
|
25
|
+
☐ Add test coverage
|
package/changelog.md
CHANGED
package/client/package.json
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@nuxtjs/google-fonts": "^1.3.0",
|
|
11
11
|
"@nuxtjs/tailwindcss": "^5.0.4",
|
|
12
|
-
"@nuxtus/cli": "^1.0.
|
|
13
|
-
"@nuxtus/generator": "1.
|
|
14
|
-
"nuxt": "3.0.0-rc.4"
|
|
12
|
+
"@nuxtus/cli": "^1.0.6",
|
|
13
|
+
"@nuxtus/generator": "1.1.0",
|
|
14
|
+
"nuxt": "3.0.0-rc.4",
|
|
15
|
+
"openapi-typescript": "^5.4.1"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@headlessui/vue": "^1.6.1",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
2
|
-
const config = useRuntimeConfig()
|
|
3
|
-
const { login } = useDirectusAuth()
|
|
4
2
|
try {
|
|
3
|
+
const config = useRuntimeConfig()
|
|
4
|
+
const { login } = useDirectusAuth()
|
|
5
5
|
await login({
|
|
6
6
|
email: config.public.directusEmail,
|
|
7
7
|
password: config.public.directusPassword,
|
|
@@ -3,8 +3,13 @@ import { createPage } from "@nuxtus/generator"
|
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
4
|
if (process.env.NODE_ENV !== "production") {
|
|
5
5
|
const body = await useBody(event)
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
try {
|
|
7
|
+
const collection = body.collection
|
|
8
|
+
createPage(collection, body.singleton)
|
|
9
|
+
} catch (err) {
|
|
10
|
+
console.error(err.message)
|
|
11
|
+
throw new Error("Unable to create page: " + err.message)
|
|
12
|
+
}
|
|
8
13
|
return {
|
|
9
14
|
api: "ok",
|
|
10
15
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import axios from "axios"
|
|
2
|
+
import fs from "fs"
|
|
3
|
+
import openapiTS from "openapi-typescript"
|
|
4
|
+
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
if (process.env.NODE_ENV !== "production") {
|
|
7
|
+
const config = useRuntimeConfig()
|
|
8
|
+
// TODO: Can't seem to share login from directusLogin (currently client only plugin)
|
|
9
|
+
try {
|
|
10
|
+
const { data } = await axios.post("http://localhost:8055/auth/login", {
|
|
11
|
+
email: config.public.directusEmail,
|
|
12
|
+
password: config.public.directusPassword,
|
|
13
|
+
})
|
|
14
|
+
axios.defaults.headers.common[
|
|
15
|
+
"Authorization"
|
|
16
|
+
] = `Bearer ${data.data.access_token}`
|
|
17
|
+
} catch (err) {
|
|
18
|
+
console.error("Failed to login to Directus: " + err.message)
|
|
19
|
+
throw err
|
|
20
|
+
}
|
|
21
|
+
const openapi = await axios.get("http://localhost:8055/server/specs/oas")
|
|
22
|
+
// console.log(JSON.stringify(openapi.data.components.schemas))
|
|
23
|
+
const types = await openapiTS(openapi.data)
|
|
24
|
+
if (!fs.existsSync("interfaces")) {
|
|
25
|
+
fs.mkdirSync("interfaces")
|
|
26
|
+
}
|
|
27
|
+
fs.writeFileSync("interfaces/nuxtus.ts", types)
|
|
28
|
+
return {
|
|
29
|
+
api: "ok",
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtus/nuxtus",
|
|
3
3
|
"description": "Directus/Nuxt boilerplate with Tailwind CSS.",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/nuxtus/nuxtus.git"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"registry": "https://registry.npmjs.org/"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"client": "cd client && npm run dev",
|
|
27
|
+
"client": "cd client && npm run dev -- -o",
|
|
28
28
|
"server": "cd server && npx directus start",
|
|
29
29
|
"start": "concurrently \"npm run client\" \"npm run server\""
|
|
30
30
|
},
|