{"id":26546665,"url":"https://github.com/serhii-chernenko/nuxt-layers-cloudflare","last_synced_at":"2026-04-17T08:01:56.918Z","repository":{"id":283742323,"uuid":"952692754","full_name":"serhii-chernenko/nuxt-layers-cloudflare","owner":"serhii-chernenko","description":"Repo for recreating issues of Cloudflare + Wrangler integrations for monorepo with Nuxt Layers DDD architecture","archived":false,"fork":false,"pushed_at":"2025-03-24T22:11:35.000Z","size":147,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T03:36:15.791Z","etag":null,"topics":["cloudflare","d1","drizzle-kit","drizzle-orm","nitro","nuxt","pages","wrangler"],"latest_commit_sha":null,"homepage":"https://nuxt-layers-cloudflare.pages.dev/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serhii-chernenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-21T17:58:40.000Z","updated_at":"2025-03-24T22:11:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a3630ac-fcf9-44aa-aac9-48c7b4dd968c","html_url":"https://github.com/serhii-chernenko/nuxt-layers-cloudflare","commit_stats":null,"previous_names":["serhii-chernenko/nuxt-layers-cloudflare"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/serhii-chernenko/nuxt-layers-cloudflare","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhii-chernenko%2Fnuxt-layers-cloudflare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhii-chernenko%2Fnuxt-layers-cloudflare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhii-chernenko%2Fnuxt-layers-cloudflare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhii-chernenko%2Fnuxt-layers-cloudflare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serhii-chernenko","download_url":"https://codeload.github.com/serhii-chernenko/nuxt-layers-cloudflare/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhii-chernenko%2Fnuxt-layers-cloudflare/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31920518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare","d1","drizzle-kit","drizzle-orm","nitro","nuxt","pages","wrangler"],"created_at":"2025-03-22T05:19:48.282Z","updated_at":"2026-04-17T08:01:56.868Z","avatar_url":"https://github.com/serhii-chernenko.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nuxt 3 Layers with Cloudflare Pages integration\n\nThis is an example repository that introduce DDD architecture via [Nuxt 3 Layers](https://nuxt.com/docs/getting-started/layers) \nwith integrations of [`nitro-cloudflare-dev`](https://github.com/nitrojs/nitro-cloudflare-dev) module for development and production purposes via [Wrangler](https://www.npmjs.com/package/wrangler).\n\nA similar repository but without the layers architecture is available here:\n- Repo: https://github.com/serhii-chernenko/falling-hall-643e/\n- URL: https://falling-hall-643e.pages.dev/\n\nIt has the same issues as the current one.\n\n## Updates\n\n### Fix for [Issue 1](#issue-1)\n\nPR with fixes to the Nitro repository:\nhttps://github.com/nitrojs/nitro/pull/3245\n\nIt allows to set a custom path of auto-generated `wrangler.json` file.\n\n### Fix for [Issue 2](#issue-2) and [Issue 3](#issue-3)\n\nhttps://github.com/nitrojs/nitro-cloudflare-dev/issues/57#issuecomment-2747722537\n\n## Useful links\n\n- [Nuxt Cloudflare Pages docs](https://developers.cloudflare.com/pages/framework-guides/deploy-a-nuxt-site/)\n- [Cloudflare workers local development](https://developers.cloudflare.com/workers/local-development/)\n- [Cloudflare D1 local development](https://developers.cloudflare.com/d1/best-practices/local-development/)\n\n## Setup project\n\nTo setup current repository follow next step\n\n1. Prepare project\n    - Run the command `git clone git@github.com:serhii-chernenko/nuxt-layers-cloudflare.git`.\n    - Install packages `npm i`.\n2. Prepare Cloudflare instances:\n    - Run `npx wrangler login` to connect your account.\n    - Create a new D1 database `npx wrangler d1 create nuxt-layers-cloudflare`\n    - Save the value of the `database_id` field for the next step.\n3. Setup project:\n    - Prepare `.env` file `cp src/apps/app/.env.example src/apps/app/.env`.\n    - Insert the value of `database_id` (from the previous step) to the `DB_ITEMS_ID` env variable.\n    - Build all layers `npm run dev:prepare`.\n    - Build the end application `npm run build:app`. [Go to Suggestion 1](#suggestion-1)\n    - Generate DB migrations `npm run db:generate`.\n    - Run the end application `npm run dev:app`. [Go to Issue 1](#issue-1)\n4. Use wrangler for dev preview and deploy\n    - Run `npx wrangler pages deploy --cwd src/apps/app/dist`. [Go to Issue 2](#issue-2)\n    - Run `npx wrangler pages dev --cwd src/apps/app/dist`. [Go to Issue 3](#issue-3)\n  \n## Suggestions\n\n### Suggestion 1\n\nEven for local development, I need the `wrangler.json` file. But it generates on a fly only on the `nuxt build` command. It'd be nice to trigger the generation for `nuxt dev` as well.\n\n## Issues\n\n### Issue 1\n\n#### Error\n\nDB connections error\n```\nQuery: select \"id\", \"name\", \"created_at\" from \"items\"\n\nERROR  D1_ERROR: no such table: items: SQLITE_ERROR\n```\n\n#### Fix attempt\n\nI tried to apply the migration by the command from the root directory:\n```bash\nnpx wrangler d1 migrations apply DB_ITEMS --local -c src/apps/app/dist/_worker.js/wrangler.json\n```\nThe output:\n```\n[ERROR] table `items` already exists at offset 13: SQLITE_ERROR\n```\nSo, I'm really confused, why it says that the `items` table already exists but when I try to run development it says the opposite.\n\n#### Solution\n\nhttps://github.com/nitrojs/nitro/pull/3245\n\n### Issue 2\n\nURL: https://nuxt-layers-cloudflare.pages.dev/\n\nResult is the same as locally — \"Internal server error\" but in the production mode the root cause is not displayed:\n![image](https://github.com/user-attachments/assets/a163c2b8-0ed6-4031-bbcf-7b25ed738401)\n\nLet's go the next step to debug the issue.\n\n#### Solution\n\nhttps://github.com/nitrojs/nitro-cloudflare-dev/issues/57#issuecomment-2747722537\n\n### Issue 3\n\nRunning output:\n```\nYour worker has access to the following bindings:\n- D1 Databases:\n  - DB_ITEMS: nuxt-layers-cloudflare (53f8****-****-****-****-********6160) [simulated locally]\n```\n\nError when the page is opened in the browser by pressing `b`:\n```\n✘ [ERROR] TypeError: Cannot read properties of undefined (reading 'env') at useDatabaseItems\n```\n\n#### Solution\n\nhttps://github.com/nitrojs/nitro-cloudflare-dev/issues/57#issuecomment-2747722537\n\n## Short summary\n\nIt's impossible to develop project locally with D1 instance. It doesn't work via `wrangler pages dev` and `wrangler pages deploy` as well.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserhii-chernenko%2Fnuxt-layers-cloudflare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserhii-chernenko%2Fnuxt-layers-cloudflare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserhii-chernenko%2Fnuxt-layers-cloudflare/lists"}