From 59968d9c83f4d56a2fe94d2f62f3444b458d4133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Tue, 20 Feb 2024 23:51:57 +0100 Subject: [PATCH 1/6] chore(release): v0.1.0 --- CHANGELOG.md | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +- 2 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..6d299e54 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,176 @@ +# Changelog + + +## v0.1.0 + + +### 🚀 Enhancements + +- **kv:** Add VK composable & route + notes demo page ([883b4d8](https://github.com/nuxt-hub/core/commit/883b4d8)) +- **r2:** Tests ([92e996f](https://github.com/nuxt-hub/core/commit/92e996f)) +- Add database tables inspection ([3fa8b99](https://github.com/nuxt-hub/core/commit/3fa8b99)) +- Add primary keys and indexes ([3364822](https://github.com/nuxt-hub/core/commit/3364822)) +- Support D1 as proxy ([081179d](https://github.com/nuxt-hub/core/commit/081179d)) +- Add index columns ([2c14405](https://github.com/nuxt-hub/core/commit/2c14405)) +- ⚠️ Remove config, remove drizzle, export proxy utils ([3538004](https://github.com/nuxt-hub/core/commit/3538004)) +- Add intAsString on zod ([80f9cd1](https://github.com/nuxt-hub/core/commit/80f9cd1)) +- Add ensureBlob ([2b5ce33](https://github.com/nuxt-hub/core/commit/2b5ce33)) +- Cli and rename env variables ([5b0a167](https://github.com/nuxt-hub/core/commit/5b0a167)) +- Improve cli ([7310e1a](https://github.com/nuxt-hub/core/commit/7310e1a)) +- **cli:** Add link command and refactor utils ([9231341](https://github.com/nuxt-hub/core/commit/9231341)) +- Support proxy ([9f187ac](https://github.com/nuxt-hub/core/commit/9f187ac)) +- Add unlink command ([a734a0f](https://github.com/nuxt-hub/core/commit/a734a0f)) +- Remove cli and improve logging ([4dbc18f](https://github.com/nuxt-hub/core/commit/4dbc18f)) +- **docs:** Initial documentation ([77116ca](https://github.com/nuxt-hub/core/commit/77116ca)) +- Refactor as module ([c0a6b83](https://github.com/nuxt-hub/core/commit/c0a6b83)) + +### 🩹 Fixes + +- **hub:** Ignore mkdir error when `.hub/` already exists ([f934cee](https://github.com/nuxt-hub/core/commit/f934cee)) +- Error handling ([a041a94](https://github.com/nuxt-hub/core/commit/a041a94)) +- Types ([e0ee310](https://github.com/nuxt-hub/core/commit/e0ee310)) +- **storage:** Upload route ([28d97fa](https://github.com/nuxt-hub/core/commit/28d97fa)) +- Proxy stream workaround ([d1f7bcd](https://github.com/nuxt-hub/core/commit/d1f7bcd)) +- Package.json typo ([d3b6b48](https://github.com/nuxt-hub/core/commit/d3b6b48)) +- Return empty array if no tables ([718b624](https://github.com/nuxt-hub/core/commit/718b624)) +- Remove config usage and support redirect ([af0d593](https://github.com/nuxt-hub/core/commit/af0d593)) +- Support when no CF binding ([00aa6b6](https://github.com/nuxt-hub/core/commit/00aa6b6)) +- Add nuxt-auth-utils module ([9025154](https://github.com/nuxt-hub/core/commit/9025154)) +- Add missing dep and improve demo ([9bb75ba](https://github.com/nuxt-hub/core/commit/9bb75ba)) +- Small update ([14c3d7a](https://github.com/nuxt-hub/core/commit/14c3d7a)) +- Final ([7fb9f15](https://github.com/nuxt-hub/core/commit/7fb9f15)) +- ⚠️ Remove useHub() composable ([93cc08f](https://github.com/nuxt-hub/core/commit/93cc08f)) +- Return if correct ([993639f](https://github.com/nuxt-hub/core/commit/993639f)) +- Improve primitives fetching ([8ab4fd1](https://github.com/nuxt-hub/core/commit/8ab4fd1)) +- Use projectKey ([16382a4](https://github.com/nuxt-hub/core/commit/16382a4)) + +### 💅 Refactors + +- Rename `bucket` to `blob` ([0a94b4e](https://github.com/nuxt-hub/core/commit/0a94b4e)) + +### 🏡 Chore + +- Wip ([c475cde](https://github.com/nuxt-hub/core/commit/c475cde)) +- Update ([8c7c036](https://github.com/nuxt-hub/core/commit/8c7c036)) +- Update ([4a6d41c](https://github.com/nuxt-hub/core/commit/4a6d41c)) +- Update ([a41546f](https://github.com/nuxt-hub/core/commit/a41546f)) +- Rename to nuxthub ([eb0ff3d](https://github.com/nuxt-hub/core/commit/eb0ff3d)) +- Up ([8554469](https://github.com/nuxt-hub/core/commit/8554469)) +- Update notes form ([2ab7fe8](https://github.com/nuxt-hub/core/commit/2ab7fe8)) +- Add dev and prod utils ([51c4140](https://github.com/nuxt-hub/core/commit/51c4140)) +- Up ([ef38aa0](https://github.com/nuxt-hub/core/commit/ef38aa0)) +- Up ([7728586](https://github.com/nuxt-hub/core/commit/7728586)) +- Fix for prod ([8da732a](https://github.com/nuxt-hub/core/commit/8da732a)) +- Upload file to storage ([1f85aba](https://github.com/nuxt-hub/core/commit/1f85aba)) +- Improve storage form ([49e7936](https://github.com/nuxt-hub/core/commit/49e7936)) +- RequireSession first ([82e16ae](https://github.com/nuxt-hub/core/commit/82e16ae)) +- **storage:** Put & get file ([01b0bd7](https://github.com/nuxt-hub/core/commit/01b0bd7)) +- Add storage deletion ([4fe0349](https://github.com/nuxt-hub/core/commit/4fe0349)) +- **storage:** Add delete action & files preview ([d2d1fa0](https://github.com/nuxt-hub/core/commit/d2d1fa0)) +- Improve error logging ([1faf68d](https://github.com/nuxt-hub/core/commit/1faf68d)) +- **storage:** Allow multiple files upload ([d3bf027](https://github.com/nuxt-hub/core/commit/d3bf027)) +- **storage:** Attempt to serve file from route url ([a956284](https://github.com/nuxt-hub/core/commit/a956284)) +- **storage:** Move bucket crud logic in `useBlob` ([c97f5a9](https://github.com/nuxt-hub/core/commit/c97f5a9)) +- **storage:** Add production hub api routes ([3974989](https://github.com/nuxt-hub/core/commit/3974989)) +- **storage:** Improve file customMetadata ([0fdd01b](https://github.com/nuxt-hub/core/commit/0fdd01b)) +- **storage:** Update demo page ([890b770](https://github.com/nuxt-hub/core/commit/890b770)) +- **storage:** Update production hub api routes ([ba927e6](https://github.com/nuxt-hub/core/commit/ba927e6)) +- **storage:** Up (enable nitro asyncContext) ([3c81ba4](https://github.com/nuxt-hub/core/commit/3c81ba4)) +- Update README ([7f5833e](https://github.com/nuxt-hub/core/commit/7f5833e)) +- Remove kv prefix ([3b4ee43](https://github.com/nuxt-hub/core/commit/3b4ee43)) +- **storage:** Improve page display ([7ceee8f](https://github.com/nuxt-hub/core/commit/7ceee8f)) +- Improve multipart files parsing ([09a580d](https://github.com/nuxt-hub/core/commit/09a580d)) +- Bucket changes ([3594bfb](https://github.com/nuxt-hub/core/commit/3594bfb)) +- **storage:** Test-blob ([850f668](https://github.com/nuxt-hub/core/commit/850f668)) +- **storage:** Clean and type useBlob ([20d6ea0](https://github.com/nuxt-hub/core/commit/20d6ea0)) +- Adds logs command ([cd7d1e3](https://github.com/nuxt-hub/core/commit/cd7d1e3)) +- **storage:** Update upload route ([329e932](https://github.com/nuxt-hub/core/commit/329e932)) +- **storage:** Serve blob + deps ([7ac3252](https://github.com/nuxt-hub/core/commit/7ac3252)) +- **storage:** Up ([5d4b0b1](https://github.com/nuxt-hub/core/commit/5d4b0b1)) +- **storage:** Up ([92abb27](https://github.com/nuxt-hub/core/commit/92abb27)) +- Try to decode pathname ([1da7e19](https://github.com/nuxt-hub/core/commit/1da7e19)) +- Prepare hub server api authorization ([d97b03a](https://github.com/nuxt-hub/core/commit/d97b03a)) +- Clean code ([0ae27d8](https://github.com/nuxt-hub/core/commit/0ae27d8)) +- Remove `readFormDataFixed` ([3cd35fc](https://github.com/nuxt-hub/core/commit/3cd35fc)) +- **blob:** Attempt to put on proxy ([73a01cb](https://github.com/nuxt-hub/core/commit/73a01cb)) +- **blob:** Put workaround (no stream) ([44a0561](https://github.com/nuxt-hub/core/commit/44a0561)) +- **blob:** Up ([61e402d](https://github.com/nuxt-hub/core/commit/61e402d)) +- Use ofetch for proxy requests ([ab70d7a](https://github.com/nuxt-hub/core/commit/ab70d7a)) +- Remove zod imports ([c15adce](https://github.com/nuxt-hub/core/commit/c15adce)) +- Lint config + indent ([1f5ddf0](https://github.com/nuxt-hub/core/commit/1f5ddf0)) +- **config:** Utils ([975a0fb](https://github.com/nuxt-hub/core/commit/975a0fb)) +- **auth:** Dynamic provider server route ([b6a9715](https://github.com/nuxt-hub/core/commit/b6a9715)) +- Client public config composable ([3cfc682](https://github.com/nuxt-hub/core/commit/3cfc682)) +- Up ([dcd1e38](https://github.com/nuxt-hub/core/commit/dcd1e38)) +- **kv:** Use binding in local ([e6fa288](https://github.com/nuxt-hub/core/commit/e6fa288)) +- Lint ([5223aef](https://github.com/nuxt-hub/core/commit/5223aef)) +- Improve loggings ([77e6800](https://github.com/nuxt-hub/core/commit/77e6800)) +- Split kv & config ([61f32f2](https://github.com/nuxt-hub/core/commit/61f32f2)) +- Up ([acfbd4e](https://github.com/nuxt-hub/core/commit/acfbd4e)) +- Move to layer structure ([0f1bb0c](https://github.com/nuxt-hub/core/commit/0f1bb0c)) +- Fix tsconfig ([c163243](https://github.com/nuxt-hub/core/commit/c163243)) +- Leverage useHub().auth ([e5817b1](https://github.com/nuxt-hub/core/commit/e5817b1)) +- Lint ([17e9d5e](https://github.com/nuxt-hub/core/commit/17e9d5e)) +- **release:** Release v0.0.1 ([ffdcc0a](https://github.com/nuxt-hub/core/commit/ffdcc0a)) +- Public package ([b69fe4b](https://github.com/nuxt-hub/core/commit/b69fe4b)) +- Update package name ([cb30ffd](https://github.com/nuxt-hub/core/commit/cb30ffd)) +- **auth:** Provider success hook ([8cbe7cb](https://github.com/nuxt-hub/core/commit/8cbe7cb)) +- **release:** Release v0.0.2 ([62d8c5a](https://github.com/nuxt-hub/core/commit/62d8c5a)) +- Handle fresh env variable ([f0c52ec](https://github.com/nuxt-hub/core/commit/f0c52ec)) +- **release:** Release v0.0.3 ([f581166](https://github.com/nuxt-hub/core/commit/f581166)) +- Fix demo ([2c4b7fb](https://github.com/nuxt-hub/core/commit/2c4b7fb)) +- **release:** Release v0.0.4 ([34251cf](https://github.com/nuxt-hub/core/commit/34251cf)) +- **release:** Release v0.0.5 ([a814c49](https://github.com/nuxt-hub/core/commit/a814c49)) +- **release:** Release v0.1.0 ([ab3215b](https://github.com/nuxt-hub/core/commit/ab3215b)) +- **release:** Release v0.1.1 ([3dfb576](https://github.com/nuxt-hub/core/commit/3dfb576)) +- Add typecheck command ([0f40fdb](https://github.com/nuxt-hub/core/commit/0f40fdb)) +- Fix & typecheck ([1965479](https://github.com/nuxt-hub/core/commit/1965479)) +- **release:** Release v0.1.2 ([8a75419](https://github.com/nuxt-hub/core/commit/8a75419)) +- **release:** Release v0.1.3 ([c17f871](https://github.com/nuxt-hub/core/commit/c17f871)) +- **analytics:** Add beacon plugin (experimental) ([6f0a271](https://github.com/nuxt-hub/core/commit/6f0a271)) +- **analytics:** Update ([92381d8](https://github.com/nuxt-hub/core/commit/92381d8)) +- **analytics:** Remove beacon plugin ([6357fa9](https://github.com/nuxt-hub/core/commit/6357fa9)) +- **analytics:** Add to wrangler ([c2850a0](https://github.com/nuxt-hub/core/commit/c2850a0)) +- **analytics:** Server composable (WIP) ([5d0f321](https://github.com/nuxt-hub/core/commit/5d0f321)) +- Update deps ([381a81a](https://github.com/nuxt-hub/core/commit/381a81a)) +- **release:** Release v0.1.4 ([322bf7e](https://github.com/nuxt-hub/core/commit/322bf7e)) +- **release:** Release v0.1.5 ([e05886f](https://github.com/nuxt-hub/core/commit/e05886f)) +- **release:** Release v0.1.6 ([0d9a875](https://github.com/nuxt-hub/core/commit/0d9a875)) +- **release:** Release v0.1.7 ([4fececd](https://github.com/nuxt-hub/core/commit/4fececd)) +- **release:** Release v0.1.8 ([4bd5fdf](https://github.com/nuxt-hub/core/commit/4bd5fdf)) +- **release:** Release v0.1.9 ([f2ca1ee](https://github.com/nuxt-hub/core/commit/f2ca1ee)) +- Update deps ([c02bd87](https://github.com/nuxt-hub/core/commit/c02bd87)) +- **release:** Release v0.2.0 ([53add24](https://github.com/nuxt-hub/core/commit/53add24)) +- **release:** Release v0.2.1 ([2cbef5e](https://github.com/nuxt-hub/core/commit/2cbef5e)) +- **release:** Release v0.2.2 ([5726a95](https://github.com/nuxt-hub/core/commit/5726a95)) +- Ignore on prepare ([08d42e1](https://github.com/nuxt-hub/core/commit/08d42e1)) +- Update module ([62cf3f2](https://github.com/nuxt-hub/core/commit/62cf3f2)) +- **release:** Release v0.2.3 ([fd0ce56](https://github.com/nuxt-hub/core/commit/fd0ce56)) +- Add projectId ([8885057](https://github.com/nuxt-hub/core/commit/8885057)) +- **release:** Release v0.2.4 ([859eecc](https://github.com/nuxt-hub/core/commit/859eecc)) +- Update lock ([9fedc8b](https://github.com/nuxt-hub/core/commit/9fedc8b)) +- Add primitives check ([e212046](https://github.com/nuxt-hub/core/commit/e212046)) +- Improve logging ([abf16e8](https://github.com/nuxt-hub/core/commit/abf16e8)) +- **release:** Release v0.2.5 ([1f8943a](https://github.com/nuxt-hub/core/commit/1f8943a)) +- **release:** Release v0.2.6 ([b235d84](https://github.com/nuxt-hub/core/commit/b235d84)) +- **ci:** Update ci ([93ce83c](https://github.com/nuxt-hub/core/commit/93ce83c)) +- Update permissions for ci ([a4e6a67](https://github.com/nuxt-hub/core/commit/a4e6a67)) +- Update playground design ([047f0ba](https://github.com/nuxt-hub/core/commit/047f0ba)) +- **test:** Add missing import ([a33371f](https://github.com/nuxt-hub/core/commit/a33371f)) +- **playground:** Add basic auth ([fbb042b](https://github.com/nuxt-hub/core/commit/fbb042b)) +- **docs:** Update ([d10328a](https://github.com/nuxt-hub/core/commit/d10328a)) +- Update types command ([b19d4a5](https://github.com/nuxt-hub/core/commit/b19d4a5)) +- Update types ([b3d0739](https://github.com/nuxt-hub/core/commit/b3d0739)) +- Update deps ([e8095ad](https://github.com/nuxt-hub/core/commit/e8095ad)) +- Update ([60dba2b](https://github.com/nuxt-hub/core/commit/60dba2b)) + +#### ⚠️ Breaking Changes + +- ⚠️ Remove config, remove drizzle, export proxy utils ([3538004](https://github.com/nuxt-hub/core/commit/3538004)) +- ⚠️ Remove useHub() composable ([93cc08f](https://github.com/nuxt-hub/core/commit/93cc08f)) + +### ❤️ Contributors + +- Sébastien Chopin ([@Atinux](http://github.com/Atinux)) +- Sylvain Marroufin ([@smarroufin](http://github.com/smarroufin)) + diff --git a/package.json b/package.json index e387b3c3..2af8d5ba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nuxthub/core", "private": false, - "version": "0.0.1", + "version": "0.1.0", "description": "Nuxt Toolkit to create full-stack applications on the Edge.", "repository": "nuxt-hub/core", "license": "Apache-2.0", @@ -67,4 +67,4 @@ "vitest": "^1.3.1", "vue-tsc": "^1.8.27" } -} +} \ No newline at end of file From 8ca7a0430534daed15f229d07cdfe105b8c222f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Tue, 20 Feb 2024 23:57:20 +0100 Subject: [PATCH 2/6] docs: update package name --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fef34f8f..99f71d4c 100644 --- a/README.md +++ b/README.md @@ -17,28 +17,28 @@ Read more on https://docs.hub.nuxt.com ## Quick Setup -1. Add `@nuxt/hub` dependency to your project +1. Add `@nuxthub/core` dependency to your project ```bash # Using pnpm -pnpm add @nuxt/hub +pnpm add @nuxthub/core # Using yarn -yarn add @nuxt/hub +yarn add @nuxthub/core # Using npm -npm install @nuxt/hub +npm install @nuxthub/core # Using bun -npm add @nuxt/hub +npm add @nuxthub/core ``` -2. Add `@nuxt/hub` to the `modules` section of `nuxt.config.ts` +2. Add `@nuxthub/core` to the `modules` section of `nuxt.config.ts` ```js export default defineNuxtConfig({ modules: [ - '@nuxt/hub' + '@nuxthub/core' ] }) ``` From 53485ac367ff7fa252cb0812bead8f4eac4b7adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 21 Feb 2024 10:38:37 +0100 Subject: [PATCH 3/6] fix: add missing imports --- .nuxtrc | 3 +++ package.json | 7 ++----- playground/nuxt.config.ts | 5 ++++- src/module.ts | 8 +++++++- src/runtime/server/api/_hub/analytics/index.put.ts | 1 + .../server/api/_hub/blob/[...pathname].delete.ts | 3 +++ src/runtime/server/api/_hub/blob/[...pathname].get.ts | 3 +++ .../server/api/_hub/blob/[...pathname].head.ts | 3 +++ src/runtime/server/api/_hub/blob/[...pathname].put.ts | 3 +++ src/runtime/server/api/_hub/blob/index.get.ts | 2 ++ .../server/api/_hub/database/[command].post.ts | 3 +++ src/runtime/server/api/_hub/index.head.ts | 2 ++ src/runtime/server/api/_hub/kv/[...path].ts | 1 + src/runtime/server/api/_hub/primitives.get.ts | 2 ++ src/runtime/server/middleware/1.hub-auth.ts | 2 ++ src/runtime/server/plugins/cloudflare.dev.ts | 11 ++++++++--- src/runtime/server/tsconfig.json | 3 --- src/runtime/server/utils/analytics.ts | 1 + src/runtime/server/utils/blob.ts | 1 + src/runtime/server/utils/database.ts | 1 + src/runtime/server/utils/hooks.ts | 1 + src/runtime/server/utils/kv.ts | 1 + tsconfig.json | 8 +------- 23 files changed, 55 insertions(+), 20 deletions(-) delete mode 100644 src/runtime/server/tsconfig.json diff --git a/.nuxtrc b/.nuxtrc index 7e85ad93..94781c74 100644 --- a/.nuxtrc +++ b/.nuxtrc @@ -1,2 +1,5 @@ +# imports.autoImport=false +typescript.includeWorkspace=true + # enable TypeScript bundler module resolution - https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler experimental.typescriptBundlerResolution=true diff --git a/package.json b/package.json index 2af8d5ba..754ac9a8 100644 --- a/package.json +++ b/package.json @@ -25,11 +25,8 @@ "dev:build": "nuxi build playground", "docs": "nuxi dev docs", "docs:build": "nuxi build docs", - "release": "npm run lint && npm run typecheck && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags", + "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags", "lint": "eslint .", - "typecheck": "npm run test:types && npm run test:types:playground", - "test:types": "vue-tsc --noEmit", - "test:types:playground": "cd playground && vue-tsc --noEmit", "test": "vitest run", "test:watch": "vitest watch" }, @@ -67,4 +64,4 @@ "vitest": "^1.3.1", "vue-tsc": "^1.8.27" } -} \ No newline at end of file +} diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts index 93aee5be..e22eea4d 100644 --- a/playground/nuxt.config.ts +++ b/playground/nuxt.config.ts @@ -1,7 +1,7 @@ export default defineNuxtConfig({ devtools: { enabled: true }, modules: [ - '../src/module', + '@nuxthub/core', '@nuxt/ui', '@kgierke/nuxt-basic-auth' ], @@ -19,5 +19,8 @@ export default defineNuxtConfig({ password: process.env.NUXT_ADMIN_PASSWORD || 'admin' } ] + }, + imports: { + autoImport: true } }) diff --git a/src/module.ts b/src/module.ts index a879877e..914de7ab 100644 --- a/src/module.ts +++ b/src/module.ts @@ -8,6 +8,7 @@ import { readUser } from 'rc9' import { $fetch } from 'ofetch' import { joinURL } from 'ufo' import { generateWrangler } from './utils' +import { version } from '../package.json' const log = logger.withScope('nuxt:hub') @@ -52,7 +53,9 @@ export interface ModuleOptions { export default defineNuxtModule({ meta: { - name: 'hub' + name: '@nuxthub/core', + configKey: 'hub', + version }, defaults: { remote: false @@ -77,6 +80,9 @@ export default defineNuxtModule({ }) addServerScanDir(resolve('./runtime/server')) + nuxt.options.nitro.externals = nuxt.options.nitro.externals || {} + nuxt.options.nitro.externals.inline = nuxt.options.nitro.externals.inline || [] + nuxt.options.nitro.externals.inline.push(resolve('./runtime/server/')) // nuxt prepare or production mode, stop here if (nuxt.options._prepare || !nuxt.options.dev) { diff --git a/src/runtime/server/api/_hub/analytics/index.put.ts b/src/runtime/server/api/_hub/analytics/index.put.ts index eac11d3c..0bf7adaa 100644 --- a/src/runtime/server/api/_hub/analytics/index.put.ts +++ b/src/runtime/server/api/_hub/analytics/index.put.ts @@ -1,4 +1,5 @@ import type { AnalyticsEngineDataPoint } from '@cloudflare/workers-types/experimental' +import { eventHandler, readValidatedBody } from 'h3' export default eventHandler(async (event) => { const { data } = await readValidatedBody(event, z.object({ diff --git a/src/runtime/server/api/_hub/blob/[...pathname].delete.ts b/src/runtime/server/api/_hub/blob/[...pathname].delete.ts index 7bad2330..f1d7ee19 100644 --- a/src/runtime/server/api/_hub/blob/[...pathname].delete.ts +++ b/src/runtime/server/api/_hub/blob/[...pathname].delete.ts @@ -1,3 +1,6 @@ +import { eventHandler, getValidatedRouterParams } from 'h3' +import { z } from 'zod' + export default eventHandler(async (event) => { const { pathname } = await getValidatedRouterParams(event, z.object({ pathname: z.string().min(1) diff --git a/src/runtime/server/api/_hub/blob/[...pathname].get.ts b/src/runtime/server/api/_hub/blob/[...pathname].get.ts index 6f17f76a..241621f6 100644 --- a/src/runtime/server/api/_hub/blob/[...pathname].get.ts +++ b/src/runtime/server/api/_hub/blob/[...pathname].get.ts @@ -1,3 +1,6 @@ +import { eventHandler, getValidatedRouterParams } from 'h3' +import { z } from 'zod' + export default eventHandler(async (event) => { // TODO: handle caching in production const { pathname } = await getValidatedRouterParams(event, z.object({ diff --git a/src/runtime/server/api/_hub/blob/[...pathname].head.ts b/src/runtime/server/api/_hub/blob/[...pathname].head.ts index 6158c8af..14a02993 100644 --- a/src/runtime/server/api/_hub/blob/[...pathname].head.ts +++ b/src/runtime/server/api/_hub/blob/[...pathname].head.ts @@ -1,3 +1,6 @@ +import { eventHandler, getValidatedRouterParams, setHeader, sendNoContent } from 'h3' +import { z } from 'zod' + export default eventHandler(async (event) => { const { pathname } = await getValidatedRouterParams(event, z.object({ pathname: z.string().min(1) diff --git a/src/runtime/server/api/_hub/blob/[...pathname].put.ts b/src/runtime/server/api/_hub/blob/[...pathname].put.ts index 81ab662a..9f6740e2 100644 --- a/src/runtime/server/api/_hub/blob/[...pathname].put.ts +++ b/src/runtime/server/api/_hub/blob/[...pathname].put.ts @@ -1,3 +1,6 @@ +import { eventHandler, getValidatedRouterParams, getHeader, getRequestWebStream } from 'h3' +import { z } from 'zod' + async function streamToArrayBuffer(stream: ReadableStream, streamSize: number) { const result = new Uint8Array(streamSize) let bytesRead = 0 diff --git a/src/runtime/server/api/_hub/blob/index.get.ts b/src/runtime/server/api/_hub/blob/index.get.ts index 88d5c0fe..9b0b8b2d 100644 --- a/src/runtime/server/api/_hub/blob/index.get.ts +++ b/src/runtime/server/api/_hub/blob/index.get.ts @@ -1,3 +1,5 @@ +import { eventHandler } from 'h3' + export default eventHandler(async () => { return useBlob().list() }) diff --git a/src/runtime/server/api/_hub/database/[command].post.ts b/src/runtime/server/api/_hub/database/[command].post.ts index 52b6433c..f1edb26c 100644 --- a/src/runtime/server/api/_hub/database/[command].post.ts +++ b/src/runtime/server/api/_hub/database/[command].post.ts @@ -1,3 +1,6 @@ +import { eventHandler, getValidatedRouterParams, readValidatedBody } from 'h3' +import { z } from 'zod' + const statementValidation = z.object({ query: z.string().min(1).max(1e6).trim(), params: z.any().array(), diff --git a/src/runtime/server/api/_hub/index.head.ts b/src/runtime/server/api/_hub/index.head.ts index 907eb6fa..a63aba47 100644 --- a/src/runtime/server/api/_hub/index.head.ts +++ b/src/runtime/server/api/_hub/index.head.ts @@ -1 +1,3 @@ +import { eventHandler, sendNoContent } from 'h3' + export default eventHandler((event) => sendNoContent(event)) diff --git a/src/runtime/server/api/_hub/kv/[...path].ts b/src/runtime/server/api/_hub/kv/[...path].ts index 51e2b68c..9bb12a8e 100644 --- a/src/runtime/server/api/_hub/kv/[...path].ts +++ b/src/runtime/server/api/_hub/kv/[...path].ts @@ -1,3 +1,4 @@ +import { eventHandler } from 'h3' import { createH3StorageHandler } from 'unstorage/server' export default eventHandler(async (event) => { diff --git a/src/runtime/server/api/_hub/primitives.get.ts b/src/runtime/server/api/_hub/primitives.get.ts index d397c2fc..f19f0e8e 100644 --- a/src/runtime/server/api/_hub/primitives.get.ts +++ b/src/runtime/server/api/_hub/primitives.get.ts @@ -1,3 +1,5 @@ +import { eventHandler } from 'h3' + export default eventHandler(async () => { const [ dbCheck, kvCheck, blobCheck ] = await Promise.all([ falseIfFail(() => useDatabase().exec('PRAGMA table_list')), diff --git a/src/runtime/server/middleware/1.hub-auth.ts b/src/runtime/server/middleware/1.hub-auth.ts index ce40ed14..e5d8c558 100644 --- a/src/runtime/server/middleware/1.hub-auth.ts +++ b/src/runtime/server/middleware/1.hub-auth.ts @@ -1,4 +1,6 @@ +import { eventHandler, getHeader, createError } from 'h3' import { $fetch } from 'ofetch' +import { useRuntimeConfig } from '#imports' export default eventHandler(async (event) => { // Skip if not a hub request diff --git a/src/runtime/server/plugins/cloudflare.dev.ts b/src/runtime/server/plugins/cloudflare.dev.ts index 753a7cf7..f0bab40d 100644 --- a/src/runtime/server/plugins/cloudflare.dev.ts +++ b/src/runtime/server/plugins/cloudflare.dev.ts @@ -1,7 +1,13 @@ -export default defineNitroPlugin(async (nitroApp) => { +import type { H3Event } from 'h3' +import type { NitroApp } from 'nitropack' +// @ts-ignore +import { defineNitroPlugin, useRuntimeConfig } from '#imports' +import { hubHooks } from '../utils/hooks' + +export default defineNitroPlugin(async (nitroApp: NitroApp) => { const proxyPromise = getBindingsProxy() - nitroApp.hooks.hook('request', async (event) => { + nitroApp.hooks.hook('request', async (event: H3Event) => { const proxy = await proxyPromise // Inject proxy bindings to the request context // https://github.com/unjs/nitro/blob/main/src/runtime/entries/cloudflare-pages.ts @@ -49,7 +55,6 @@ async function getBindingsProxy() { } }) - // @ts-ignore await hubHooks.callHook('bindings:ready') return proxy diff --git a/src/runtime/server/tsconfig.json b/src/runtime/server/tsconfig.json deleted file mode 100644 index 0e35e645..00000000 --- a/src/runtime/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../../.nuxt/tsconfig.server.json" -} diff --git a/src/runtime/server/utils/analytics.ts b/src/runtime/server/utils/analytics.ts index 994f9e32..2130c66b 100644 --- a/src/runtime/server/utils/analytics.ts +++ b/src/runtime/server/utils/analytics.ts @@ -1,6 +1,7 @@ import type { AnalyticsEngineDataPoint, AnalyticsEngineDataset } from '@cloudflare/workers-types/experimental' import { ofetch } from 'ofetch' import { joinURL } from 'ufo' +import { useRuntimeConfig } from '#imports' const _datasets: Record = {} diff --git a/src/runtime/server/utils/blob.ts b/src/runtime/server/utils/blob.ts index 33c3bb7b..87e7223b 100644 --- a/src/runtime/server/utils/blob.ts +++ b/src/runtime/server/utils/blob.ts @@ -8,6 +8,7 @@ import { defu } from 'defu' import { randomUUID } from 'uncrypto' import { parse } from 'pathe' import { joinURL } from 'ufo' +import { useRuntimeConfig } from '#imports' export interface BlobObject { pathname: string diff --git a/src/runtime/server/utils/database.ts b/src/runtime/server/utils/database.ts index ed6bd284..b9a63d3d 100644 --- a/src/runtime/server/utils/database.ts +++ b/src/runtime/server/utils/database.ts @@ -2,6 +2,7 @@ import type { D1Database } from '@cloudflare/workers-types/experimental' import { ofetch } from 'ofetch' import { joinURL } from 'ufo' import type { H3Error } from 'h3' +import { useRuntimeConfig } from '#imports' let _db: D1Database diff --git a/src/runtime/server/utils/hooks.ts b/src/runtime/server/utils/hooks.ts index 2110e444..11767c72 100644 --- a/src/runtime/server/utils/hooks.ts +++ b/src/runtime/server/utils/hooks.ts @@ -1,3 +1,4 @@ +import { useRuntimeConfig } from '#imports' import { createHooks } from 'hookable' export interface HubHooks { diff --git a/src/runtime/server/utils/kv.ts b/src/runtime/server/utils/kv.ts index a734f7ca..9c08abc7 100644 --- a/src/runtime/server/utils/kv.ts +++ b/src/runtime/server/utils/kv.ts @@ -3,6 +3,7 @@ import { createStorage } from 'unstorage' import httpDriver from 'unstorage/drivers/http' import cloudflareKVBindingDriver from 'unstorage/drivers/cloudflare-kv-binding' import { joinURL } from 'ufo' +import { useRuntimeConfig } from '#imports' let _kv: Storage diff --git a/tsconfig.json b/tsconfig.json index 49b2d99a..4b34df15 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,3 @@ { - "extends": "./.nuxt/tsconfig.json", - "exclude": [ - "playground", - "src/module/runtime/server", - "docs", - "dist" - ] + "extends": "./.nuxt/tsconfig.json" } From 34e955a4303d6880a94207cf8d5f757f565ecfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 21 Feb 2024 10:45:10 +0100 Subject: [PATCH 4/6] chore(ci): add nightly --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 972e3861..e70ca88a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,8 +66,9 @@ jobs: - name: Run test suite run: pnpm test - - name: Test types - run: pnpm test:types - - - name: Test playground types - run: pnpm test:types:playground + - name: Release Nightly + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: pnpm changelogen --bump --canary --publish --publishTag nightly + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + NPM_CONFIG_PROVENANCE: true From 0dacd0fca477081ca24a347d34f709feb2f9ee3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 21 Feb 2024 10:48:40 +0100 Subject: [PATCH 5/6] chore: update module import --- playground/nuxt.config.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts index e22eea4d..93aee5be 100644 --- a/playground/nuxt.config.ts +++ b/playground/nuxt.config.ts @@ -1,7 +1,7 @@ export default defineNuxtConfig({ devtools: { enabled: true }, modules: [ - '@nuxthub/core', + '../src/module', '@nuxt/ui', '@kgierke/nuxt-basic-auth' ], @@ -19,8 +19,5 @@ export default defineNuxtConfig({ password: process.env.NUXT_ADMIN_PASSWORD || 'admin' } ] - }, - imports: { - autoImport: true } }) From 8950351a2db093bf15fd4614edc05db2538a28a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 21 Feb 2024 10:49:04 +0100 Subject: [PATCH 6/6] chore: fix package repo --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 754ac9a8..e12c05f8 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "private": false, "version": "0.1.0", "description": "Nuxt Toolkit to create full-stack applications on the Edge.", - "repository": "nuxt-hub/core", + "repository": { + "type": "git", + "url": "git+https://github.com/nuxt-hub/core.git" + }, "license": "Apache-2.0", "type": "module", "exports": {