Skip to content

Commit 42c00b0

Browse files
committed
fix imports
1 parent 4d768e7 commit 42c00b0

9 files changed

Lines changed: 71 additions & 58 deletions

File tree

packages/start-nitro-v2-plugin/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,16 @@ export function nitroV2Plugin(nitroConfig?: UserNitroConfig): PluginOption {
9797
],
9898
renderer: virtualEntry,
9999
rollupConfig: {
100-
...nitroConfig?.rollupConfig,
100+
...nitroConfig?.rollupConfig,
101101
plugins: [virtualBundlePlugin(ssrBundle) as any],
102102
},
103-
experimental: { ...nitroConfig?.experimental, asyncContext: true },
103+
experimental: {
104+
...nitroConfig?.experimental,
105+
asyncContext: true,
106+
},
104107
virtual: {
105-
...nitroConfig?.virtual,
106-
[virtualEntry]: `import { fromWebHandler } from 'h3'
108+
...nitroConfig?.virtual,
109+
[virtualEntry]: `import { fromWebHandler } from 'h3-v1'
107110
import handler from '${ssrEntryFile}'
108111
export default fromWebHandler(handler.fetch)`,
109112
},

packages/start/src/http/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { H3Event, HTTPEvent, InferEventInput } from "h3-v2";
2-
import * as h3 from "h3-v2";
1+
import type { H3Event, HTTPEvent, InferEventInput } from "h3";
2+
import * as h3 from "h3";
33
import { getRequestEvent } from "solid-js/web";
44

55
function _setContext(event: H3Event, key: string, value: any) {
Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @refresh skip
22

3-
import { H3Event, Middleware } from "h3-v2";
3+
import type { H3Event, Middleware } from "h3";
44
import { getFetchEvent } from "../server/fetchEvent.ts";
55
import type { FetchEvent } from "../server/types.ts";
66

@@ -35,41 +35,48 @@ function wrapRequestMiddleware(onRequest: RequestMiddleware) {
3535
};
3636
}
3737

38-
function wrapResponseMiddleware(onBeforeResponse: ResponseMiddleware): Middleware {
39-
return async (
40-
h3Event,
41-
next
42-
) => {
43-
const resp = await next();
38+
function wrapResponseMiddleware(
39+
onBeforeResponse: ResponseMiddleware,
40+
): Middleware {
41+
return async (h3Event, next) => {
42+
const resp = await next();
4443

4544
const fetchEvent = getFetchEvent(h3Event);
46-
const mwResponse = await onBeforeResponse(fetchEvent, {body: (resp as any)?.body });
47-
if (mwResponse) return mwResponse
45+
const mwResponse = await onBeforeResponse(fetchEvent, {
46+
body: (resp as any)?.body,
47+
});
48+
if (mwResponse) return mwResponse;
4849
};
4950
}
5051

51-
export function createMiddleware(args: {
52-
/** @deprecated Use H3 `Middleware` */
53-
onRequest?: RequestMiddleware | RequestMiddleware[] | undefined;
54-
/** @deprecated Use H3 `Middleware` */
55-
onBeforeResponse?: ResponseMiddleware | ResponseMiddleware[] | undefined;
56-
} | Middleware[]): Middleware[] {
57-
if(Array.isArray(args)) return args
52+
export function createMiddleware(
53+
args:
54+
| {
55+
/** @deprecated Use H3 `Middleware` */
56+
onRequest?: RequestMiddleware | RequestMiddleware[] | undefined;
57+
/** @deprecated Use H3 `Middleware` */
58+
onBeforeResponse?:
59+
| ResponseMiddleware
60+
| ResponseMiddleware[]
61+
| undefined;
62+
}
63+
| Middleware[],
64+
): Middleware[] {
65+
if (Array.isArray(args)) return args;
5866

59-
const mw: Middleware[] = [];
67+
const mw: Middleware[] = [];
6068

61-
if(typeof args.onRequest === "function") {
62-
mw.push(wrapRequestMiddleware(args.onRequest));
63-
} else if (Array.isArray(args.onRequest)) {
64-
mw.push(...args.onRequest.map(wrapRequestMiddleware));
65-
}
69+
if (typeof args.onRequest === "function") {
70+
mw.push(wrapRequestMiddleware(args.onRequest));
71+
} else if (Array.isArray(args.onRequest)) {
72+
mw.push(...args.onRequest.map(wrapRequestMiddleware));
73+
}
6674

67-
if(typeof args.onBeforeResponse === "function") {
68-
mw.push(wrapResponseMiddleware(args.onBeforeResponse));
69-
} else if (Array.isArray(args.onBeforeResponse)) {
70-
mw.push(...args.onBeforeResponse.map(wrapResponseMiddleware));
71-
}
75+
if (typeof args.onBeforeResponse === "function") {
76+
mw.push(wrapResponseMiddleware(args.onBeforeResponse));
77+
} else if (Array.isArray(args.onBeforeResponse)) {
78+
mw.push(...args.onBeforeResponse.map(wrapResponseMiddleware));
79+
}
7280

73-
74-
return mw
81+
return mw;
7582
}

packages/start/src/server/fetchEvent.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1+
import * as h3 from "h3";
12
import { beforeEach, describe, expect, it, vi } from "vitest";
2-
import * as h3 from "h3-v2";
33

44
import {
55
createFetchEvent,
66
getFetchEvent,
77
mergeResponseHeaders,
88
} from "./fetchEvent.ts";
99

10-
vi.mock(import("h3-v2"), async (mod) => {
11-
return ({
12-
...(await mod()),
13-
getRequestIP: vi.fn(),
14-
})
10+
vi.mock(import("h3"), async (mod) => {
11+
return {
12+
...(await mod()),
13+
getRequestIP: vi.fn(),
14+
};
1515
});
1616

1717
const mockedH3 = vi.mocked(h3);
1818

1919
const createMockH3Event = (): h3.H3Event => {
20-
const event = new h3.H3Event(new Request("http://localhost/test"));
20+
const event = new h3.H3Event(new Request("http://localhost/test"));
2121

22-
event.res.status = 200;
23-
event.res.statusText = "OK"
22+
event.res.status = 200;
23+
event.res.statusText = "OK";
2424

25-
return event;
25+
return event;
2626
};
2727

2828
describe("fetchEvent", () => {
@@ -82,8 +82,8 @@ describe("fetchEvent", () => {
8282

8383
mergeResponseHeaders(mockH3Event, headers);
8484

85-
expect(headers.get("content-type")).toBe("application/json")
86-
expect(headers.get("x-custom")).toBe("value")
85+
expect(headers.get("content-type")).toBe("application/json");
86+
expect(headers.get("x-custom")).toBe("value");
8787
});
8888
});
8989
});

packages/start/src/server/fetchEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getRequestIP, type H3Event } from "h3-v2";
1+
import { getRequestIP, type H3Event } from "h3";
22
import type { FetchEvent } from "./types.ts";
33

44
const FETCH_EVENT_CONTEXT = "solidFetchEvent";

packages/start/src/server/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import middleware from "solid-start:middleware";
2-
import { defineHandler, getCookie, H3, type H3Event, setCookie } from "h3-v2";
2+
import { defineHandler, getCookie, H3, type H3Event, setCookie } from "h3";
33
import { join } from "pathe";
44
import type { JSX } from "solid-js";
55
import { sharedConfig } from "solid-js";

packages/start/src/server/server-functions-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import serverFnManifest from "solidstart:server-fn-manifest";
22
import { parseSetCookie } from "cookie-es";
3-
import { type H3Event, parseCookies } from "h3-v2";
3+
import { type H3Event, parseCookies } from "h3";
44
import {
55
crossSerializeStream,
66
fromJSON,

packages/start/src/server/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { H3Event } from "h3-v2";
1+
import type { H3Event } from "h3";
22
import type { JSX } from "solid-js";
33
import type { RequestEvent } from "solid-js/web";
44

packages/start/src/virtual.d.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
declare module "solid-start:client-vite-manifest" {
2-
export const clientViteManifest: Record<string, { css?: Array<string>, file: string, [key: string]: unknown }>;
2+
export const clientViteManifest: Record<
3+
string,
4+
{ css?: Array<string>; file: string; [key: string]: unknown }
5+
>;
36
}
47

58
interface StartManifest {
6-
getAssets(id: string): Promise<import("./server/renderAsset").Asset[]>;
9+
getAssets(id: string): Promise<import("./server/renderAsset").Asset[]>;
710
}
811

912
declare module "solid-start:get-client-manifest" {
10-
export const getClientManifest: () => StartManifest;
13+
export const getClientManifest: () => StartManifest;
1114
}
1215

1316
declare module "solid-start:get-manifest" {
14-
export const getManifest: (target: "client" | "server") => StartManifest;
17+
export const getManifest: (target: "client" | "server") => StartManifest;
1518
}
1619

1720
declare module "#start/app" {
18-
export default App as import("solid-js").Component;
21+
export default App as import("solid-js").Component;
1922
}
2023

2124
declare module "solid-start:middleware" {
22-
type MaybeArray<T> = T | Array<T>;
23-
export default Middleware as import("h3-v2").Middleware[];
25+
type MaybeArray<T> = T | Array<T>;
26+
export default Middleware as import("h3").Middleware[];
2427
}

0 commit comments

Comments
 (0)