Skip to content

Commit

Permalink
fix(config): add back default storage mounts (#2853)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Nov 5, 2024
1 parent 0409601 commit cf49759
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/core/config/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type {

import { NitroDefaults } from "./defaults";

import { resolveAssetsOptions } from "./resolvers/assets";
// Resolvers
import { resolveAssetsOptions } from "./resolvers/assets";
import {
fallbackCompatibilityDate,
resolveCompatibilityOptions,
Expand All @@ -25,6 +25,7 @@ import { resolveOpenAPIOptions } from "./resolvers/open-api";
import { resolvePathOptions } from "./resolvers/paths";
import { resolveRouteRulesOptions } from "./resolvers/route-rules";
import { resolveRuntimeConfigOptions } from "./resolvers/runtime-config";
import { resolveStorageOptions } from "./resolvers/storage";
import { resolveURLOptions } from "./resolvers/url";

const configResolvers = [
Expand All @@ -39,6 +40,7 @@ const configResolvers = [
resolveOpenAPIOptions,
resolveURLOptions,
resolveAssetsOptions,
resolveStorageOptions,
] as const;

export async function loadOptions(
Expand Down
6 changes: 6 additions & 0 deletions test/fixture/api/storage/src.dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default defineEventHandler(async (event) => {
const storage = useStorage();
return {
keys: await storage.getKeys("src"),
};
});
6 changes: 6 additions & 0 deletions test/presets/nitro-dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ describe.skipIf(isCI)("nitro:preset:nitro-dev", async () => {
expect(status).toBe(200);
});

it("dev storage", async () => {
const { data } = await callHandler({ url: "/api/storage/src" });
expect(data.keys.length).toBeGreaterThan(0);
expect(data.keys).includes("src:nitro.config.ts");
});

describe("openAPI", () => {
let spec: OpenAPI3;
it("/_openapi.json", async () => {
Expand Down
5 changes: 4 additions & 1 deletion test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ type TestHandler = (options: any) => Promise<TestHandlerResult | Response>;
export function testNitro(
ctx: Context,
getHandler: () => TestHandler | Promise<TestHandler>,
additionalTests?: (ctx: Context, callHandler: TestHandler) => void
additionalTests?: (
ctx: Context,
callHandler: (options: any) => Promise<TestHandlerResult>
) => void
) {
let _handler: TestHandler;

Expand Down

0 comments on commit cf49759

Please sign in to comment.