@nestbridge/vite 2.1.4 → 2.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @nestbridge/vite
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1ca473c]
8
+ - @nestbridge/unplugin@2.3.0
9
+
10
+ ## 2.2.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 98349c7: One client can now use controllers from several NestJS apps. `nestBridge()` accepts an array of options, one entry per app, and each entry takes its own `name`, `root`, `controllers`, `resolvers`, `baseURL`, `bootstrap`, `globalPrefix` and `versioning`. A named app writes its declarations to `<outputDir>/<name>/`, detects its own response wrapper and error body from its own bootstrap file, and tags every generated request with its `name` as the `service`. A single object still works as before.
15
+
16
+ The runtime picks each request's origin from `configureNestBridge({ services })`, then the origin the plugin registered for that app with the new `setNestBridgeServiceBaseURL(name, baseURL)`, then the global `setNestBridgeBaseURL()` value. `graphqlEndpoint` also accepts a record with one endpoint per app.
17
+
18
+ `@Controller({ path, version })` and `@Version(...)` are now read, and the global prefix (`setGlobalPrefix`, including `exclude`) and URI versioning (`enableVersioning`) are detected from the bootstrap file and composed into every request path with the new `detectGlobalPrefix`, `detectVersioning` and `applyApplicationRouting` from `@nestbridge/core`. A prefix or versioning setup that cannot be read statically is reported as an `unsupported-global-prefix` or `unsupported-versioning` diagnostic; the `globalPrefix` and `versioning` plugin options state the value explicitly, and `false` ignores it.
19
+
20
+ Upgrading: the global prefix and URI versioning are now part of every URL, so a prefix that was written into `baseURL` as a workaround would now be repeated. Keep `baseURL` to the origin, or set `globalPrefix: false` / `versioning: false`. A relative `root` now resolves against the bundler's root instead of `process.cwd()`. See `MIGRATION.md`.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [98349c7]
25
+ - @nestbridge/unplugin@2.2.0
26
+
3
27
  ## 2.1.4
4
28
 
5
29
  ### Patch Changes
package/README.md CHANGED
@@ -71,28 +71,79 @@ no `baseUrl` is needed (TypeScript 7 removed that option).
71
71
  Add `.nestbridge/` (or your configured `outputDir`) to `.gitignore` — it's
72
72
  regenerated on every build and on every dev-server start.
73
73
 
74
+ ## Several server apps
75
+
76
+ To use controllers from more than one NestJS app, pass an array — one entry per
77
+ app. Each entry needs a `name`, and its `root` should be that app's folder:
78
+
79
+ ```ts
80
+ nestBridge([
81
+ {
82
+ name: 'identity',
83
+ root: '../identity',
84
+ controllers: 'src/**/*.controller.ts',
85
+ baseURL: 'https://identity.example.com',
86
+ },
87
+ {
88
+ name: 'store',
89
+ root: '../store',
90
+ controllers: 'src/**/*.controller.ts',
91
+ baseURL: 'https://store.example.com',
92
+ },
93
+ ]);
94
+ ```
95
+
96
+ A relative `root` resolves against Vite's `root`. Declarations land in
97
+ `<outputDir>/<name>/`, so add one alias and one `paths` entry per app
98
+ (`"@identity/*": ["./.nestbridge/identity/src/*"]`), and each app keeps its own
99
+ `baseURL`, bootstrap file, global prefix and versioning. See
100
+ [Several server apps](../../README.md#several-server-apps) in the repository
101
+ README, and [`MIGRATION.md`](../../MIGRATION.md) when upgrading from 2.1.
102
+
74
103
  ## `NestBridgeOptions`
75
104
 
76
105
  ```ts
77
106
  interface NestBridgeOptions {
78
- controllers: string | string[]; // glob(s), resolved relative to `root`
79
- resolvers?: string | string[]; // glob(s) for GraphQL resolvers; defaults to none
80
- baseURL?: string; // prefix for REST requests and the default GraphQL endpoint; applied to the runtime automatically
81
- debug?: boolean; // logs discovery/analysis/watch activity
107
+ name?: string; // names the server app; required, and unique, when you pass several apps
108
+ controllers: string | string[]; // glob(s), resolved relative to `root`
109
+ resolvers?: string | string[]; // glob(s) for GraphQL resolvers; defaults to none
110
+ baseURL?: string; // origin (or mount path) for this app's REST requests and its default GraphQL endpoint; applied to the runtime automatically
111
+ bootstrap?: string; // the app's bootstrap file, relative to `root`; skips the `main.ts` search
112
+ globalPrefix?: string | GlobalPrefixOption | false; // replaces the prefix read from `setGlobalPrefix()`; `false` ignores it
113
+ versioning?: VersioningOption | false; // replaces the versioning read from `enableVersioning()`; `false` ignores it
114
+ debug?: boolean; // logs discovery/analysis/watch activity
82
115
  outputDir?: string; // defaults to ".nestbridge", resolved from the Vite root — independent of `root`
83
- root?: string; // base for discovering controllers/resolvers and the bootstrap file; defaults to the Vite root
116
+ root?: string; // base for discovering controllers/resolvers and the bootstrap file; relative paths resolve against the Vite root, which is also the default
117
+ }
118
+
119
+ interface GlobalPrefixOption {
120
+ prefix: string;
121
+ exclude?: (string | { path: string; httpMethod?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' })[];
122
+ }
123
+
124
+ interface VersioningOption {
125
+ prefix?: string; // defaults to "v"; use "" for none
126
+ defaultVersion?: string; // version of routes that state none
84
127
  }
85
128
  ```
86
129
 
130
+ `nestBridge()` takes a `NestBridgeOptions` object, or an array of them
131
+ (`NestBridgePluginOptions`). All of these types are exported.
132
+
87
133
  Using webpack instead of Vite? See [`@nestbridge/webpack`'s README](../webpack/README.md)
88
134
  for the equivalent setup — same options, same generated output, different
89
135
  bundler.
90
136
 
91
137
  `baseURL` needs no extra runtime code: the plugin generates a module that
92
- calls `setNestBridgeBaseURL(baseURL)` from `nestbridge`, and every generated
93
- controller and resolver module imports it. Use `configureNestBridge` from
94
- `nestbridge` only for headers, a custom `fetch`, or an explicit
95
- `graphqlEndpoint`.
138
+ calls `setNestBridgeBaseURL(baseURL)` from `nestbridge` (or
139
+ `setNestBridgeServiceBaseURL(name, baseURL)` for a named app), and every
140
+ generated controller and resolver module imports it. Use `configureNestBridge`
141
+ from `nestbridge` only for headers, a custom `fetch`, an explicit
142
+ `graphqlEndpoint`, or per-environment `services` origins.
143
+
144
+ The global prefix and URI versioning that the app's bootstrap file sets are
145
+ read statically and added to every request path, so keep `baseURL` to the
146
+ origin — see [Global prefix and URI versioning](../../README.md#global-prefix-and-uri-versioning).
96
147
 
97
148
  ## License
98
149
 
@@ -1,10 +1,10 @@
1
- import { NestBridgeOptions, NestBridgeOptions as NestBridgeOptions$1 } from "@nestbridge/unplugin";
1
+ import { GlobalPrefixOption, NestBridgeOptions, NestBridgePluginOptions, NestBridgePluginOptions as NestBridgePluginOptions$1, VersioningOption } from "@nestbridge/unplugin";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/version.d.ts
4
4
  export declare const VERSION: string;
5
5
  //#endregion
6
6
  //#region src/main.d.ts
7
- export declare const nestBridge: (options: NestBridgeOptions$1) => Plugin;
7
+ export declare const nestBridge: (options: NestBridgePluginOptions$1) => Plugin;
8
8
  //#endregion
9
- export type { NestBridgeOptions };
9
+ export type { GlobalPrefixOption, NestBridgeOptions, NestBridgePluginOptions, VersioningOption };
10
10
  //# sourceMappingURL=nestbridge.vite.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { nestBridgeUnplugin } from "@nestbridge/unplugin";
2
2
  //#endregion
3
3
  //#region src/version.ts
4
- var VERSION = "2.1.4";
4
+ var VERSION = "2.3.0";
5
5
  //#endregion
6
6
  //#region src/main.ts
7
7
  var nestBridge = nestBridgeUnplugin.vite;
@@ -1 +1 @@
1
- {"version":3,"file":"nestbridge.vite.js","names":[],"sources":["../package.json","../src/version.ts","../src/main.ts"],"sourcesContent":["{\n \"name\": \"@nestbridge/vite\",\n \"version\": \"2.1.4\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/MDReal32/nestbridge.git\",\n \"directory\": \"packages/vite\"\n },\n \"main\": \"./build/nestbridge.vite.js\",\n \"types\": \"./build/nestbridge.vite.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./build/nestbridge.vite.d.ts\",\n \"import\": \"./build/nestbridge.vite.js\"\n }\n },\n \"files\": [\n \"build\"\n ],\n \"scripts\": {\n \"build\": \"vite build\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"lint\": \"biome check .\"\n },\n \"dependencies\": {\n \"@nestbridge/unplugin\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.4.1\",\n \"rolldown-plugin-dts\": \"^0.28.5\",\n \"typescript\": \"^7.0.2\",\n \"vite\": \"^8.2.2\",\n \"vitest\": \"^5.0.0\"\n },\n \"peerDependencies\": {\n \"vite\": \"^8.2.2\"\n }\n}\n","import { version } from '../package.json';\n\nexport const VERSION: string = version;\n","import { type NestBridgeOptions, nestBridgeUnplugin } from '@nestbridge/unplugin';\nimport type { Plugin } from 'vite';\n\nexport type { NestBridgeOptions } from '@nestbridge/unplugin';\nexport const nestBridge: (options: NestBridgeOptions) => Plugin = nestBridgeUnplugin.vite;\nexport { VERSION } from './version';\n"],"mappings":";;;ACEA,IAAa,UAAkB;;;ACE/B,IAAa,aAAqD,mBAAmB"}
1
+ {"version":3,"file":"nestbridge.vite.js","names":[],"sources":["../package.json","../src/version.ts","../src/main.ts"],"sourcesContent":["{\n \"name\": \"@nestbridge/vite\",\n \"version\": \"2.3.0\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/MDReal32/nestbridge.git\",\n \"directory\": \"packages/vite\"\n },\n \"main\": \"./build/nestbridge.vite.js\",\n \"types\": \"./build/nestbridge.vite.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./build/nestbridge.vite.d.ts\",\n \"import\": \"./build/nestbridge.vite.js\"\n }\n },\n \"files\": [\n \"build\"\n ],\n \"scripts\": {\n \"build\": \"vite build\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"lint\": \"biome check .\"\n },\n \"dependencies\": {\n \"@nestbridge/unplugin\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.4.1\",\n \"rolldown-plugin-dts\": \"^0.28.5\",\n \"typescript\": \"^7.0.2\",\n \"vite\": \"^8.2.2\",\n \"vitest\": \"^5.0.0\"\n },\n \"peerDependencies\": {\n \"vite\": \"^8.2.2\"\n }\n}\n","import { version } from '../package.json';\n\nexport const VERSION: string = version;\n","import { type NestBridgePluginOptions, nestBridgeUnplugin } from '@nestbridge/unplugin';\nimport type { Plugin } from 'vite';\n\nexport type {\n GlobalPrefixOption,\n NestBridgeOptions,\n NestBridgePluginOptions,\n VersioningOption,\n} from '@nestbridge/unplugin';\nexport const nestBridge: (options: NestBridgePluginOptions) => Plugin = nestBridgeUnplugin.vite;\nexport { VERSION } from './version';\n"],"mappings":";;;ACEA,IAAa,UAAkB;;;ACO/B,IAAa,aAA2D,mBAAmB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestbridge/vite",
3
- "version": "2.1.4",
3
+ "version": "2.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "lint": "biome check ."
27
27
  },
28
28
  "dependencies": {
29
- "@nestbridge/unplugin": "2.1.4"
29
+ "@nestbridge/unplugin": "2.3.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^26.4.1",