diff --git a/backend/composer.json b/backend/composer.json index 98391c6..a1e16cf 100644 --- a/backend/composer.json +++ b/backend/composer.json @@ -23,7 +23,7 @@ "require": { "craftcms/ckeditor": "4.2.0", "craftcms/cloud": "*", - "craftcms/cms": "5.4.4", + "craftcms/cms": "5.4.6", "vlucas/phpdotenv": "^5.4.0" }, "require-dev": { diff --git a/backend/composer.lock b/backend/composer.lock index b129dc0..d812954 100644 --- a/backend/composer.lock +++ b/backend/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b54f06ff516d6df23a55607f01799b68", + "content-hash": "0076db2c59e8ccbb13f9dd502830ee8f", "packages": [ { "name": "99designs/http-signatures", @@ -542,11 +542,11 @@ }, { "name": "craftcms/cms", - "version": "5.4.4", + "version": "5.4.6", "dist": { "type": "zip", - "url": "https://api.github.com/repos/craftcms/cms/zipball/e7eaf2a7378419fa5cd359196b0c16e5813dc85f", - "reference": "e7eaf2a7378419fa5cd359196b0c16e5813dc85f", + "url": "https://api.github.com/repos/craftcms/cms/zipball/d44a2d4628b02db2290ecff4248ba70f664c070d", + "reference": "d44a2d4628b02db2290ecff4248ba70f664c070d", "shasum": "" }, "require": { @@ -643,7 +643,7 @@ "docs": "https://craftcms.com/docs/5.x/", "rss": "https://github.com/craftcms/cms/releases.atom" }, - "time": "2024-09-14T16:48:59+00:00" + "time": "2024-09-27T18:53:45+00:00" }, { "name": "craftcms/flysystem", @@ -1730,15 +1730,15 @@ }, { "name": "lcobucci/clock", - "version": "3.2.0", + "version": "3.3.1", "dist": { "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/6f28b826ea01306b07980cb8320ab30b966cd715", - "reference": "6f28b826ea01306b07980cb8320ab30b966cd715", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/db3713a61addfffd615b79bf0bc22f0ccc61b86b", + "reference": "db3713a61addfffd615b79bf0bc22f0ccc61b86b", "shasum": "" }, "require": { - "php": "~8.2.0 || ~8.3.0", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0", "psr/clock": "^1.0" }, "provide": { @@ -1760,7 +1760,7 @@ } ], "description": "Yet another clock abstraction", - "time": "2023-11-17T17:00:27+00:00" + "time": "2024-09-24T20:45:14+00:00" }, { "name": "league/flysystem", @@ -2170,11 +2170,11 @@ }, { "name": "moneyphp/money", - "version": "v4.5.0", + "version": "v4.5.1", "dist": { "type": "zip", - "url": "https://api.github.com/repos/moneyphp/money/zipball/a1daa7daf159b4044e3d0c34c41fe2be5860e850", - "reference": "a1daa7daf159b4044e3d0c34c41fe2be5860e850", + "url": "https://api.github.com/repos/moneyphp/money/zipball/142107bec4870ac2586057dc2fe917d25c92a91e", + "reference": "142107bec4870ac2586057dc2fe917d25c92a91e", "shasum": "" }, "require": { @@ -2226,7 +2226,7 @@ "money", "vo" ], - "time": "2024-02-15T19:47:21+00:00" + "time": "2024-09-27T12:04:27+00:00" }, { "name": "monolog/monolog", @@ -2767,32 +2767,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.31.0", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "249f15fb843bf240cf058372dad29e100cee6c17" - }, + "version": "1.32.0", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/249f15fb843bf240cf058372dad29e100cee6c17", - "reference": "249f15fb843bf240cf058372dad29e100cee6c17", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, - "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^4.15", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", - "symfony/process": "^5.2" - }, "type": "library", "autoload": { "psr-4": { @@ -2801,16 +2785,11 @@ ] } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "PHPDoc parser with support for nullable, intersection and generic types", - "support": { - "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.31.0" - }, - "time": "2024-09-22T11:32:18+00:00" + "time": "2024-09-26T07:23:32+00:00" }, { "name": "pixelandtonic/imagine", diff --git a/backend/config/project/graphql/schemas/c7d2eb61-cdde-4a76-88a9-eb30ddcf155b.yaml b/backend/config/project/graphql/schemas/c7d2eb61-cdde-4a76-88a9-eb30ddcf155b.yaml index 9898722..54d1021 100644 --- a/backend/config/project/graphql/schemas/c7d2eb61-cdde-4a76-88a9-eb30ddcf155b.yaml +++ b/backend/config/project/graphql/schemas/c7d2eb61-cdde-4a76-88a9-eb30ddcf155b.yaml @@ -1,6 +1,8 @@ isPublic: false name: Posts scope: + - 'sites.58ccb571-6c72-449f-8e7b-6f43c5d416b3:read' # Starter Nuxt + - 'sections.3e2a1a6f-88ea-477b-936d-39393f2d594f:read' # Posts - 'sections.3e2a1a6f-88ea-477b-936d-39393f2d594f:edit' # Posts - 'sections.3e2a1a6f-88ea-477b-936d-39393f2d594f:create' # Posts - 'sections.3e2a1a6f-88ea-477b-936d-39393f2d594f:save' # Posts diff --git a/backend/config/project/project.yaml b/backend/config/project/project.yaml index c3abcfe..0a3cf06 100644 --- a/backend/config/project/project.yaml +++ b/backend/config/project/project.yaml @@ -1,4 +1,4 @@ -dateModified: 1727771251 +dateModified: 1727924935 elementSources: craft\elements\Entry: - diff --git a/frontend/components/postForm.vue b/frontend/components/postForm.vue index 742d3b7..0429671 100644 --- a/frontend/components/postForm.vue +++ b/frontend/components/postForm.vue @@ -1,9 +1,84 @@ + + diff --git a/frontend/nuxt.config.js b/frontend/nuxt.config.js index 70be975..f8dfcaf 100644 --- a/frontend/nuxt.config.js +++ b/frontend/nuxt.config.js @@ -3,27 +3,31 @@ export default defineNuxtConfig({ compatibilityDate: '2024-04-03', devtools: { enabled: true }, modules: ["@nuxtjs/tailwindcss", "nuxt-graphql-client"], + runtimeConfig: { + CRAFT_URL: process.env.CRAFT_URL, + public: { + GQL_HOST: process.env.GQL_HOST, + AUTH_HEADER: process.env.AUTH_HEADER, + LIVE_PREVIEW: process.env.LIVE_PREVIEW === 'true', + CRAFT_URL: process.env.CRAFT_URL, + BASE_URL: process.env.BASE_URL + } + }, 'graphql-client': { clients: { default: { - livePreview: process.env.LIVE_PREVIEW === 'true', - host: process.env.GQL_HOST, - token: process.env.LIVE_PREVIEW === 'true' ? process.env.AUTH_HEADER : '', + host: process.env.GQL_HOST }, posts: { host: process.env.GQL_HOST, - token: process.env.AUTH_HEADER - } - }, - tokenStorage: { - name: '__session', - mode: 'cookie', // default - cookieOptions: { - path: '/', - secure: true, // defaults to `process.env.NODE_ENV === 'production'` - httpOnly: false, // Only accessible via HTTP(S) - maxAge: 60 * 60 * 24 * 5 // 5 days + token: { + type: 'Bearer', + name: 'Authorization', + value: process.env.AUTH_HEADER + }, + retainToken: true, + enableMutation: true } - } + } } }); \ No newline at end of file diff --git a/frontend/queries/article.gql b/frontend/queries/default/article.gql similarity index 100% rename from frontend/queries/article.gql rename to frontend/queries/default/article.gql diff --git a/frontend/queries/blog.gql b/frontend/queries/default/blog.gql similarity index 100% rename from frontend/queries/blog.gql rename to frontend/queries/default/blog.gql diff --git a/frontend/queries/globals.gql b/frontend/queries/default/globals.gql similarity index 100% rename from frontend/queries/globals.gql rename to frontend/queries/default/globals.gql diff --git a/frontend/queries/guestbook.gql b/frontend/queries/default/guestbook.gql similarity index 99% rename from frontend/queries/guestbook.gql rename to frontend/queries/default/guestbook.gql index 4d140a6..115491c 100644 --- a/frontend/queries/guestbook.gql +++ b/frontend/queries/default/guestbook.gql @@ -18,3 +18,4 @@ query Guestbook($limit: Int!, $offset: Int!) { } entryCount(section: "posts") } + diff --git a/frontend/queries/home.gql b/frontend/queries/default/home.gql similarity index 100% rename from frontend/queries/home.gql rename to frontend/queries/default/home.gql diff --git a/frontend/queries/posts/posts.gql b/frontend/queries/posts/posts.gql new file mode 100644 index 0000000..4138ca8 --- /dev/null +++ b/frontend/queries/posts/posts.gql @@ -0,0 +1,10 @@ +mutation createPost($title: String!, $message: String) { + save_posts_text_Entry( + title: $title, + textBlock: $message, + authorId: 1 + ) { + title + textBlock + } +} \ No newline at end of file diff --git a/frontend/schema.graphql b/frontend/schema.graphql new file mode 100644 index 0000000..053397c --- /dev/null +++ b/frontend/schema.graphql @@ -0,0 +1,13 @@ +type Mutation { + save_posts_text_Entry(title: String!, textBlock: String): Entry +} + +type Entry { + id: ID + title: String + textBlock: String +} + +type Query { + entries: [Entry] +} \ No newline at end of file diff --git a/frontend/server/api/csrf.js b/frontend/server/api/csrf.js new file mode 100644 index 0000000..fc508bd --- /dev/null +++ b/frontend/server/api/csrf.js @@ -0,0 +1,37 @@ +import { $fetch } from 'ofetch' + +export default defineEventHandler(async (event) => { + const config = useRuntimeConfig() + console.log('Server config:', config) // For debugging + + const craftUrl = config.CRAFT_URL + + if (!craftUrl) { + console.error('CRAFT_URL is not defined in server environment') + throw createError({ + statusCode: 500, + statusMessage: 'CRAFT_URL is not defined in server environment', + }) + } + + try { + const url = `${craftUrl}/actions/users/session-info` + console.log('Fetching from:', url) // For debugging + + const data = await $fetch(url, { + headers: { + 'Accept': 'application/json', + }, + }) + + console.log('Response data:', data) // For debugging + + return { csrfToken: data.csrfTokenValue } + } catch (error) { + console.error('Error fetching CSRF token:', error) + throw createError({ + statusCode: 500, + statusMessage: 'Failed to fetch CSRF token: ' + error.message, + }) + } +}) \ No newline at end of file