resolveConfig(router, appConfig, order) {
			invariant(router.type === "spa", "Invalid router mode");
			const appRoot = appConfig.root ?? process.cwd();
			const root = resolve.absolute(router.root, appRoot) ?? appRoot;
			/** @type {SPARouterSchema} */
			const spaRouter = {
				...router,
				base: router.base ?? "/",
				root,
				// @ts-ignore
				internals: {},
				handler: resolve.relative(router.handler, root),
				target: router.target ?? "browser",
				outDir: router.outDir
					? join(appRoot, router.outDir)
					: join(appRoot, ".vinxi", "build", router.name),
				order: order ?? 0,
			};

			spaRouter.internals = {
				type: routerModes.spa,
				routes: router.routes ? router.routes(spaRouter, appConfig) : undefined,
				devServer: undefined,
			};

			return spaRouter;
		}
`,
							handler,
						},
						{
							route: router.base,
							handler,
						},
					];
				}

				const { createViteHandler } = await import("./dev-server.js");
				const viteServer = await createViteHandler(router, app, serveConfig);
				const viteMiddleware = fromNodeMiddleware(viteServer.middlewares);

				function createHook(hook) {
					return async function callWebSocketHook(...args) {
						const { default: handler } = await viteServer.ssrLoadModule(
							handlerModule(router),
						);
						return await handler.__websocket__?.[hook]?.(...args);
					};
				}

				const handler = eventHandler({
					handler: async (event) => {
						await viteMiddleware(event);
						if (event.handled) {
							return;
						}
						const { default: handler } = await viteServer.ssrLoadModule(
							handlerModule(router),
						);
						return handler(event);
					},
					websocket: defineWebSocket({
						open: createHook("open"),
						close: createHook("close"),
						message: createHook("message"),
						error: createHook("error"),
						upgrade: createHook("upgrade"),
					}),
				});
				return [
					{
						route: `${router.base}/**`,
						handler,
					},
					{
						route: router.base,
						handler,
					},
				];
			},
		},
		resolveConfig(router, appConfig, order) {
			invariant(router.type === "http", "Invalid router mode");
			const appRoot = appConfig.root ?? process.cwd();
			const root = resolve.absolute(router.root, appRoot) ?? appRoot;
			/** @type {HTTPRouterSchema}