@funduck/connectrpc-fastify-nestjs 1.0.10 → 1.0.11

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/README.md CHANGED
@@ -163,6 +163,13 @@ export async function bootstrap() {
163
163
  }
164
164
  ```
165
165
 
166
+ ## Strict Mode
167
+ If **strict mode** is enabled the library will cause process to exit on errors such as missing middleware or interceptor instances.
168
+ By default, strict mode is disabled to allow more flexibility during development.
169
+
170
+ To enable it call `ConnectRPC.setStrictMode(true)` before registering any middlewares or interceptors.
171
+ To check it read `ConnectRPC.isStrictMode` property.
172
+
166
173
  ### More examples
167
174
  See `test/demo` and `examples` directories for more examples.
168
175
 
@@ -55,11 +55,19 @@ let ConnectRPCModule = ConnectRPCModule_1 = class ConnectRPCModule {
55
55
  getServer() {
56
56
  const httpAdapter = this.httpAdapterHost.httpAdapter;
57
57
  if (!httpAdapter) {
58
- throw new Error('HTTP Adapter not found');
58
+ this.logger.error('HTTP Adapter not found');
59
+ if (connectrpc_fastify_1.ConnectRPC.isStrictMode) {
60
+ throw new Error('HTTP Adapter not found');
61
+ }
62
+ return;
59
63
  }
60
64
  // For now, only Fastify is supported
61
65
  if (!(httpAdapter instanceof platform_fastify_1.FastifyAdapter)) {
62
- throw new Error('Only FastifyAdapter is supported');
66
+ this.logger.error('Only FastifyAdapter is supported');
67
+ if (connectrpc_fastify_1.ConnectRPC.isStrictMode) {
68
+ throw new Error('Only FastifyAdapter is supported');
69
+ }
70
+ return;
63
71
  }
64
72
  const fastifyAdapter = httpAdapter;
65
73
  const server = fastifyAdapter.getInstance();
@@ -74,7 +82,11 @@ let ConnectRPCModule = ConnectRPCModule_1 = class ConnectRPCModule {
74
82
  this.registerPluginCalled = true;
75
83
  const server = this.getServer();
76
84
  if (!server) {
77
- throw new Error('Fastify server instance not found');
85
+ this.logger.error('Fastify server instance not found');
86
+ if (connectrpc_fastify_1.ConnectRPC.isStrictMode) {
87
+ throw new Error('Fastify server instance not found');
88
+ }
89
+ return;
78
90
  }
79
91
  connectrpc_fastify_1.ConnectRPC.initInterceptors(this.options.interceptors || []);
80
92
  await connectrpc_fastify_1.ConnectRPC.registerFastifyPlugin(server);
@@ -82,9 +94,20 @@ let ConnectRPCModule = ConnectRPCModule_1 = class ConnectRPCModule {
82
94
  /** This is called by NestJS after the module has been initialized */
83
95
  async onModuleInit() {
84
96
  if (!this.registerPluginCalled) {
85
- throw new Error('ConnectRPCModule.onModuleInit: registerPlugin() has not been called. Please call registerPlugin() after app initialization and before server starts listening.');
97
+ this.logger.error('registerPlugin() has not been called. Please call registerPlugin() after app initialization and before server starts listening.');
98
+ if (connectrpc_fastify_1.ConnectRPC.isStrictMode) {
99
+ throw new Error('registerPlugin() has not been called. Please call registerPlugin() after app initialization and before server starts listening.');
100
+ }
101
+ return;
86
102
  }
87
103
  const server = this.getServer();
104
+ if (!server) {
105
+ this.logger.error('Fastify server instance not found');
106
+ if (connectrpc_fastify_1.ConnectRPC.isStrictMode) {
107
+ throw new Error('Fastify server instance not found');
108
+ }
109
+ return;
110
+ }
88
111
  // Initialize middlewares first
89
112
  await connectrpc_fastify_1.ConnectRPC.initMiddlewares(server, this.options.middlewares || []);
90
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connectrpc.module.js","sourceRoot":"","sources":["../src/connectrpc.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAyD;AACzD,2CAMwB;AACxB,uCAA+C;AAC/C,+DAA0D;AAG1D,MAAM,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAEtE;;;;;GAKG;AAEI,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAM3B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,UAAmC,EAAE;QAClD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,+BAAU,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,OAAO;YACL,M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3E,CAAC;;AA5GU,4CAAgB;AACX,uBAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,EAAE;IACzD,SAAS,EAAE,IAAI;CAChB,CAAC,AAFoB,CAEnB;2BAHQ,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;IA6BN,WAAA,IAAA,eAAM,EAAC,sBAAe,CAAC,CAAA;IAEvB,WAAA,IAAA,eAAM,EAAC,yBAAyB,CAAC,CAAA;qCADA,sBAAe;GA7BxC,gBAAgB,CA6G5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funduck/connectrpc-fastify-nestjs",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "author": "Oleg Milekhin <qlfunduck@gmail.com>",
5
5
  "description": "Wrapper for official @connectrpc/connect and fastify integrated into Nestjs. Simplifies configuration, type safe binding to controller, simplifies use of middlewares.",
6
6
  "main": "dist/index.js",
@@ -10,13 +10,13 @@
10
10
  "compile-proto": "cd test/demo && npx buf dep update; npx buf lint; npx buf generate",
11
11
  "test:demo": "npm run compile-proto && cd test/demo && DEBUG=true npx tsx e2e-demo.ts",
12
12
  "test": "npm run compile-proto && jest --verbose",
13
- "test:coverage": "npm run compile-proto && jest --coverage --coverageReporters=json-summary --runInBand ; npx make-coverage-badge",
13
+ "test:coverage": "npm run compile-proto && npx rimraf coverage && jest --coverage --runInBand ; npx make-coverage-badge",
14
14
  "publish:check": "npm run test && npm run test:demo && npm run build && npm publish --tag latest --access public --dry-run",
15
15
  "publish:latest": "npm run test:coverage && npm run test:demo && npm run build && npm publish --tag latest --access public"
16
16
  },
17
17
  "license": "MIT",
18
18
  "peerDependencies": {
19
- "@funduck/connectrpc-fastify": "^1.0.21",
19
+ "@funduck/connectrpc-fastify": "^1.0.22",
20
20
  "@nestjs/common": "^11.1.12",
21
21
  "@nestjs/core": "^11.1.12",
22
22
  "@nestjs/platform-fastify": "^11.1.12",
@@ -28,7 +28,7 @@
28
28
  "@bufbuild/protoc-gen-es": "^2.10.2",
29
29
  "@connectrpc/connect": "^2.1.1",
30
30
  "@connectrpc/connect-node": "^2.1.1",
31
- "@funduck/connectrpc-fastify": "^1.0.21",
31
+ "@funduck/connectrpc-fastify": "^1.0.22",
32
32
  "@nestjs/common": "^11.1.12",
33
33
  "@nestjs/core": "^11.1.12",
34
34
  "@nestjs/platform-fastify": "^11.1.12",