@vertz/ui-server 0.2.45 → 0.2.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,7 +43,17 @@ interface BunDevServerOptions {
43
43
  host?: string;
44
44
  /** API handler for full-stack mode */
45
45
  apiHandler?: (req: Request) => Promise<Response>;
46
- /** Paths to skip SSR (delegate to apiHandler). @default ['/api/'] */
46
+ /**
47
+ * API route prefix for full-stack mode. Used to build route keys and
48
+ * skipSSRPaths when skipSSRPaths is not provided explicitly.
49
+ *
50
+ * Must be non-empty when `apiHandler` is provided — the dev server uses
51
+ * the prefix to distinguish API requests from SSR requests.
52
+ *
53
+ * @default '/api'
54
+ */
55
+ apiPrefix?: string;
56
+ /** Paths to skip SSR (delegate to apiHandler). @default [`${apiPrefix}/`] */
47
57
  skipSSRPaths?: string[];
48
58
  /** OpenAPI spec options */
49
59
  openapi?: {
@@ -3596,7 +3596,6 @@ function createBunDevServer(options) {
3596
3596
  port = 3000,
3597
3597
  host = "localhost",
3598
3598
  apiHandler,
3599
- skipSSRPaths = ["/api/"],
3600
3599
  openapi,
3601
3600
  clientEntry: clientEntryOption,
3602
3601
  title = "Vertz App",
@@ -3609,6 +3608,11 @@ function createBunDevServer(options) {
3609
3608
  themeFromRequest,
3610
3609
  onRestartNeeded
3611
3610
  } = options;
3611
+ const apiPrefix = options.apiPrefix ?? "/api";
3612
+ if (apiHandler && apiPrefix === "") {
3613
+ throw new Error("apiPrefix cannot be empty in full-stack mode. The dev server uses the " + "API prefix to distinguish API requests from SSR requests. Use a non-empty " + "prefix like '/api' or '/v1'. Note: '/' normalizes to empty string.");
3614
+ }
3615
+ const skipSSRPaths = options.skipSSRPaths ?? (apiPrefix ? [`${apiPrefix}/`] : []);
3612
3616
  const faviconTag = detectFaviconTag(projectRoot);
3613
3617
  const headTags = [faviconTag, headTagsOption].filter(Boolean).join(`
3614
3618
  `);
@@ -4118,11 +4122,11 @@ if (import.meta.hot) import.meta.hot.accept();
4118
4122
  const routes = {
4119
4123
  "/__vertz_hmr": hmrShellModule
4120
4124
  };
4121
- if (openapi) {
4122
- routes["/api/openapi.json"] = () => serveOpenAPISpec();
4125
+ if (openapi && apiPrefix) {
4126
+ routes[`${apiPrefix}/openapi.json`] = () => serveOpenAPISpec();
4123
4127
  }
4124
- if (apiHandler) {
4125
- routes["/api/*"] = (req) => apiHandler(req);
4128
+ if (apiHandler && apiPrefix) {
4129
+ routes[`${apiPrefix}/*`] = (req) => apiHandler(req);
4126
4130
  }
4127
4131
  killStaleProcess(port);
4128
4132
  server = Bun.serve({
@@ -4231,7 +4235,7 @@ if (import.meta.hot) import.meta.hot.accept();
4231
4235
  }
4232
4236
  return new Response("Not Found", { status: 404 });
4233
4237
  }
4234
- if (openapi && request.method === "GET" && pathname === "/api/openapi.json") {
4238
+ if (openapi && apiPrefix && request.method === "GET" && pathname === `${apiPrefix}/openapi.json`) {
4235
4239
  return serveOpenAPISpec();
4236
4240
  }
4237
4241
  if (apiHandler && skipSSRPaths.some((p) => pathname.startsWith(p))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertz/ui-server",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
4
4
  "description": "Vertz UI server-side rendering runtime",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -67,15 +67,15 @@
67
67
  "@ampproject/remapping": "^2.3.0",
68
68
  "@capsizecss/unpack": "^4.0.0",
69
69
  "@jridgewell/trace-mapping": "^0.3.31",
70
- "@vertz/core": "^0.2.43",
71
- "@vertz/ui": "^0.2.43",
70
+ "@vertz/core": "^0.2.46",
71
+ "@vertz/ui": "^0.2.46",
72
72
  "magic-string": "^0.30.0",
73
73
  "sharp": "^0.34.5"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@happy-dom/global-registrator": "^20.8.3",
77
77
  "@playwright/test": "^1.58.2",
78
- "@vertz/codegen": "^0.2.43",
78
+ "@vertz/codegen": "^0.2.46",
79
79
  "bun-types": "^1.3.10",
80
80
  "bunup": "^0.16.31",
81
81
  "happy-dom": "^20.8.3",