Skip to content

Commit 53485ac

Browse files
committed
fix: add missing imports
1 parent 8ca7a04 commit 53485ac

23 files changed

+55
-20
lines changed

.nuxtrc

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
# imports.autoImport=false
2+
typescript.includeWorkspace=true
3+
14
# enable TypeScript bundler module resolution - https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler
25
experimental.typescriptBundlerResolution=true

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@
2525
"dev:build": "nuxi build playground",
2626
"docs": "nuxi dev docs",
2727
"docs:build": "nuxi build docs",
28-
"release": "npm run lint && npm run typecheck && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
28+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
2929
"lint": "eslint .",
30-
"typecheck": "npm run test:types && npm run test:types:playground",
31-
"test:types": "vue-tsc --noEmit",
32-
"test:types:playground": "cd playground && vue-tsc --noEmit",
3330
"test": "vitest run",
3431
"test:watch": "vitest watch"
3532
},
@@ -67,4 +64,4 @@
6764
"vitest": "^1.3.1",
6865
"vue-tsc": "^1.8.27"
6966
}
70-
}
67+
}

playground/nuxt.config.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineNuxtConfig({
22
devtools: { enabled: true },
33
modules: [
4-
'../src/module',
4+
'@nuxthub/core',
55
'@nuxt/ui',
66
'@kgierke/nuxt-basic-auth'
77
],
@@ -19,5 +19,8 @@ export default defineNuxtConfig({
1919
password: process.env.NUXT_ADMIN_PASSWORD || 'admin'
2020
}
2121
]
22+
},
23+
imports: {
24+
autoImport: true
2225
}
2326
})

src/module.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { readUser } from 'rc9'
88
import { $fetch } from 'ofetch'
99
import { joinURL } from 'ufo'
1010
import { generateWrangler } from './utils'
11+
import { version } from '../package.json'
1112

1213
const log = logger.withScope('nuxt:hub')
1314

@@ -52,7 +53,9 @@ export interface ModuleOptions {
5253

5354
export default defineNuxtModule<ModuleOptions>({
5455
meta: {
55-
name: 'hub'
56+
name: '@nuxthub/core',
57+
configKey: 'hub',
58+
version
5659
},
5760
defaults: {
5861
remote: false
@@ -77,6 +80,9 @@ export default defineNuxtModule<ModuleOptions>({
7780
})
7881

7982
addServerScanDir(resolve('./runtime/server'))
83+
nuxt.options.nitro.externals = nuxt.options.nitro.externals || {}
84+
nuxt.options.nitro.externals.inline = nuxt.options.nitro.externals.inline || []
85+
nuxt.options.nitro.externals.inline.push(resolve('./runtime/server/'))
8086

8187
// nuxt prepare or production mode, stop here
8288
if (nuxt.options._prepare || !nuxt.options.dev) {

src/runtime/server/api/_hub/analytics/index.put.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AnalyticsEngineDataPoint } from '@cloudflare/workers-types/experimental'
2+
import { eventHandler, readValidatedBody } from 'h3'
23

34
export default eventHandler(async (event) => {
45
const { data } = await readValidatedBody(event, z.object({

src/runtime/server/api/_hub/blob/[...pathname].delete.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { eventHandler, getValidatedRouterParams } from 'h3'
2+
import { z } from 'zod'
3+
14
export default eventHandler(async (event) => {
25
const { pathname } = await getValidatedRouterParams(event, z.object({
36
pathname: z.string().min(1)

src/runtime/server/api/_hub/blob/[...pathname].get.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { eventHandler, getValidatedRouterParams } from 'h3'
2+
import { z } from 'zod'
3+
14
export default eventHandler(async (event) => {
25
// TODO: handle caching in production
36
const { pathname } = await getValidatedRouterParams(event, z.object({

src/runtime/server/api/_hub/blob/[...pathname].head.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { eventHandler, getValidatedRouterParams, setHeader, sendNoContent } from 'h3'
2+
import { z } from 'zod'
3+
14
export default eventHandler(async (event) => {
25
const { pathname } = await getValidatedRouterParams(event, z.object({
36
pathname: z.string().min(1)

src/runtime/server/api/_hub/blob/[...pathname].put.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { eventHandler, getValidatedRouterParams, getHeader, getRequestWebStream } from 'h3'
2+
import { z } from 'zod'
3+
14
async function streamToArrayBuffer(stream: ReadableStream, streamSize: number) {
25
const result = new Uint8Array(streamSize)
36
let bytesRead = 0
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { eventHandler } from 'h3'
2+
13
export default eventHandler(async () => {
24
return useBlob().list()
35
})

src/runtime/server/api/_hub/database/[command].post.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { eventHandler, getValidatedRouterParams, readValidatedBody } from 'h3'
2+
import { z } from 'zod'
3+
14
const statementValidation = z.object({
25
query: z.string().min(1).max(1e6).trim(),
36
params: z.any().array(),
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
import { eventHandler, sendNoContent } from 'h3'
2+
13
export default eventHandler((event) => sendNoContent(event))

src/runtime/server/api/_hub/kv/[...path].ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { eventHandler } from 'h3'
12
import { createH3StorageHandler } from 'unstorage/server'
23

34
export default eventHandler(async (event) => {

src/runtime/server/api/_hub/primitives.get.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { eventHandler } from 'h3'
2+
13
export default eventHandler(async () => {
24
const [ dbCheck, kvCheck, blobCheck ] = await Promise.all([
35
falseIfFail(() => useDatabase().exec('PRAGMA table_list')),

src/runtime/server/middleware/1.hub-auth.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { eventHandler, getHeader, createError } from 'h3'
12
import { $fetch } from 'ofetch'
3+
import { useRuntimeConfig } from '#imports'
24

35
export default eventHandler(async (event) => {
46
// Skip if not a hub request

src/runtime/server/plugins/cloudflare.dev.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
export default defineNitroPlugin(async (nitroApp) => {
1+
import type { H3Event } from 'h3'
2+
import type { NitroApp } from 'nitropack'
3+
// @ts-ignore
4+
import { defineNitroPlugin, useRuntimeConfig } from '#imports'
5+
import { hubHooks } from '../utils/hooks'
6+
7+
export default defineNitroPlugin(async (nitroApp: NitroApp) => {
28
const proxyPromise = getBindingsProxy()
39

4-
nitroApp.hooks.hook('request', async (event) => {
10+
nitroApp.hooks.hook('request', async (event: H3Event) => {
511
const proxy = await proxyPromise
612
// Inject proxy bindings to the request context
713
// https://github.com/unjs/nitro/blob/main/src/runtime/entries/cloudflare-pages.ts
@@ -49,7 +55,6 @@ async function getBindingsProxy() {
4955
}
5056
})
5157

52-
// @ts-ignore
5358
await hubHooks.callHook('bindings:ready')
5459

5560
return proxy

src/runtime/server/tsconfig.json

-3
This file was deleted.

src/runtime/server/utils/analytics.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { AnalyticsEngineDataPoint, AnalyticsEngineDataset } from '@cloudflare/workers-types/experimental'
22
import { ofetch } from 'ofetch'
33
import { joinURL } from 'ufo'
4+
import { useRuntimeConfig } from '#imports'
45

56
const _datasets: Record<string, AnalyticsEngineDataset> = {}
67

src/runtime/server/utils/blob.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { defu } from 'defu'
88
import { randomUUID } from 'uncrypto'
99
import { parse } from 'pathe'
1010
import { joinURL } from 'ufo'
11+
import { useRuntimeConfig } from '#imports'
1112

1213
export interface BlobObject {
1314
pathname: string

src/runtime/server/utils/database.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { D1Database } from '@cloudflare/workers-types/experimental'
22
import { ofetch } from 'ofetch'
33
import { joinURL } from 'ufo'
44
import type { H3Error } from 'h3'
5+
import { useRuntimeConfig } from '#imports'
56

67
let _db: D1Database
78

src/runtime/server/utils/hooks.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useRuntimeConfig } from '#imports'
12
import { createHooks } from 'hookable'
23

34
export interface HubHooks {

src/runtime/server/utils/kv.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createStorage } from 'unstorage'
33
import httpDriver from 'unstorage/drivers/http'
44
import cloudflareKVBindingDriver from 'unstorage/drivers/cloudflare-kv-binding'
55
import { joinURL } from 'ufo'
6+
import { useRuntimeConfig } from '#imports'
67

78
let _kv: Storage
89

tsconfig.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
{
2-
"extends": "./.nuxt/tsconfig.json",
3-
"exclude": [
4-
"playground",
5-
"src/module/runtime/server",
6-
"docs",
7-
"dist"
8-
]
2+
"extends": "./.nuxt/tsconfig.json"
93
}

0 commit comments

Comments
 (0)