@kiyasov/platform-hono 1.1.9 → 1.2.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/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@kiyasov/platform-hono",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "description": "Nest adapter for Hono",
5
5
  "author": "Islam Kiiasov",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/kiyasov/platform-hono"
9
+ },
6
10
  "license": "MIT",
7
11
  "main": "./dist/cjs/index.js",
8
12
  "module": "./dist/esm/index.js",
@@ -36,11 +36,16 @@ export class HonoAdapter extends AbstractHttpAdapter<
36
36
  Context
37
37
  > {
38
38
  protected readonly instance: Hono<{ Bindings: HttpBindings }>;
39
+ private _isParserRegistered: boolean;
39
40
 
40
41
  constructor() {
41
42
  super(new Hono());
42
43
  }
43
44
 
45
+ get isParserRegistered(): boolean {
46
+ return !!this._isParserRegistered;
47
+ }
48
+
44
49
  private getRouteAndHandler(
45
50
  pathOrHandler: string | HonoHandler,
46
51
  handler?: HonoHandler
@@ -227,6 +232,10 @@ export class HonoAdapter extends AbstractHttpAdapter<
227
232
  }
228
233
  await next();
229
234
  });
235
+
236
+ // To avoid the Nest application init to override our custom
237
+ // body parser, we mark the parsers as registered.
238
+ this._isParserRegistered = true;
230
239
  }
231
240
 
232
241
  public close(): Promise<void> {
@@ -250,10 +259,16 @@ export class HonoAdapter extends AbstractHttpAdapter<
250
259
  }
251
260
 
252
261
  public registerParserMiddleware(prefix?: string, rawBody?: boolean) {
262
+ if (this._isParserRegistered) {
263
+ return;
264
+ }
265
+
253
266
  Logger.log("Registering parser middleware");
254
267
  this.useBodyParser("application/x-www-form-urlencoded");
255
268
  this.useBodyParser("application/json");
256
269
  this.useBodyParser("text/plain");
270
+
271
+ this._isParserRegistered = true;
257
272
  }
258
273
 
259
274
  public async createMiddlewareFactory(requestMethod: RequestMethod) {