diff --git a/package.json b/package.json index 1efafb80..cfd2d7c0 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "rc9": "^2.1.1", "ufo": "^1.4.0", "uncrypto": "^0.1.3", + "unstorage": "^1.10.1", "wrangler": "^3.28.3", "zod": "^3.22.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index faed4846..fa47f7ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,6 +56,9 @@ importers: uncrypto: specifier: ^0.1.3 version: 0.1.3 + unstorage: + specifier: ^1.10.1 + version: 1.10.1 wrangler: specifier: ^3.28.3 version: 3.28.3(@cloudflare/workers-types@4.20240208.0) diff --git a/src/runtime/server/utils/database.ts b/src/runtime/server/utils/database.ts index 79e0aced..ed6bd284 100644 --- a/src/runtime/server/utils/database.ts +++ b/src/runtime/server/utils/database.ts @@ -5,7 +5,7 @@ import type { H3Error } from 'h3' let _db: D1Database -export function useDatabase() { +export function useDatabase(): D1Database { if (_db) { return _db } @@ -23,7 +23,7 @@ export function useDatabase() { throw createError('Missing Cloudflare DB binding (D1)') } -export function useProxyDatabase(projectUrl: string, secretKey?: string) { +export function useProxyDatabase(projectUrl: string, secretKey?: string): D1Database { const d1API = ofetch.create({ baseURL: joinURL(projectUrl, '/api/_hub/database'), method: 'POST', diff --git a/src/runtime/server/utils/kv.ts b/src/runtime/server/utils/kv.ts index 78cc2882..a734f7ca 100644 --- a/src/runtime/server/utils/kv.ts +++ b/src/runtime/server/utils/kv.ts @@ -6,7 +6,7 @@ import { joinURL } from 'ufo' let _kv: Storage -export function useKV() { +export function useKV(): Storage { if (_kv) { return _kv } @@ -27,7 +27,7 @@ export function useKV() { throw createError('Missing Cloudflare KV binding (KV)') } -export function useProxyKV(projectUrl: string, secretKey?: string) { +export function useProxyKV(projectUrl: string, secretKey?: string): Storage { return createStorage({ driver: httpDriver({ base: joinURL(projectUrl, '/api/_hub/kv/'),