diff --git a/src/rollup/plugins/storage.ts b/src/rollup/plugins/storage.ts index 09e468bd5d..dcaf961d88 100644 --- a/src/rollup/plugins/storage.ts +++ b/src/rollup/plugins/storage.ts @@ -48,15 +48,7 @@ import { assets } from '#internal/nitro/virtual/server-assets' ${driverImports.map((i) => genImport(i, genSafeVariableName(i))).join("\n")} -const storage = createStorage({}) - -export const useStorage = (base = '') => { - if (base) { - return prefixStorage(storage, base) - } - - return storage -} +export const storage = createStorage({}) storage.mount('/assets', assets) diff --git a/src/runtime/cache.ts b/src/runtime/cache.ts index 38de73fc55..6c4e2c92f0 100644 --- a/src/runtime/cache.ts +++ b/src/runtime/cache.ts @@ -7,7 +7,7 @@ import { } from "h3"; import type { H3Event } from "h3"; import { parseURL } from "ufo"; -import { useStorage } from "#internal/nitro/virtual/storage"; +import { useStorage } from "./storage"; export interface CacheEntry { value?: T; diff --git a/src/runtime/index.ts b/src/runtime/index.ts index e9e9698128..269224370c 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -1,7 +1,7 @@ -export { useStorage } from "#internal/nitro/virtual/storage"; export { useRuntimeConfig, useAppConfig } from "./config"; export * from "./cache"; export { useNitroApp } from "./app"; export * from "./plugin"; export * from "./renderer"; export { getRouteRules } from "./route-rules"; +export { useStorage } from "./storage"; diff --git a/src/runtime/storage.ts b/src/runtime/storage.ts new file mode 100644 index 0000000000..7195ee250d --- /dev/null +++ b/src/runtime/storage.ts @@ -0,0 +1,7 @@ +import type { Storage } from "unstorage"; +import { prefixStorage } from "unstorage"; +import { storage } from "#internal/nitro/virtual/storage"; + +export function useStorage(base = ""): Storage { + return base ? prefixStorage(storage, base) : storage; +} diff --git a/src/runtime/virtual/storage.d.ts b/src/runtime/virtual/storage.d.ts index 2d85b38cbf..9df4f48cb7 100644 --- a/src/runtime/virtual/storage.d.ts +++ b/src/runtime/virtual/storage.d.ts @@ -1,3 +1,3 @@ import type { Storage } from "unstorage"; -export declare const useStorage: (base?: string) => Storage; +export declare const storage: Storage;