geonix 1.20.5 → 1.20.6

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/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export function encode(data: any): Uint8Array;
2
+ export function decode(data: any): unknown;
1
3
  export const codec: import("nats").Codec<unknown>;
2
4
  export const connection: Connection;
3
5
  export function stopConnection(): void;
@@ -168,7 +170,8 @@ export function Stream(data: any, tag?: string): any;
168
170
  export function isStream(object: any): any;
169
171
  export function getReadable(object: any): Promise<any>;
170
172
  export function streamToBuffer(object: any): Promise<any>;
171
- export function streamToString(object: any): Promise<any>;
173
+ export function streamToString(object: any, encoding: any): Promise<any>;
174
+ export function streamToJSON(object: any): Promise<any>;
172
175
  export const stats: {};
173
176
  export const activeStreams: {};
174
177
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonix",
3
- "version": "1.20.5",
3
+ "version": "1.20.6",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "bin": {
package/src/Codec.js CHANGED
@@ -12,5 +12,9 @@ export function decode(data) {
12
12
  return codec.decode(data);
13
13
  }
14
14
 
15
- throw new Error("Codec.decode: unknown data type");
15
+ try {
16
+ return codec.decode(data);
17
+ } catch {
18
+ throw new Error("Codec.decode: unknown data type");
19
+ }
16
20
  }
package/src/Service.js CHANGED
@@ -183,13 +183,13 @@ export class Service {
183
183
  const router = webserver.router();
184
184
 
185
185
  // setup defualt middlewares
186
- if (this.#options.middleware.json) {
186
+ if (this.#options.middleware?.json) {
187
187
  router.use(json);
188
188
  }
189
- if (this.#options.middleware.raw) {
189
+ if (this.#options.middleware?.raw) {
190
190
  router.use(raw);
191
191
  }
192
- if (this.#options.middleware.cookies) {
192
+ if (this.#options.middleware?.cookies) {
193
193
  router.use(cookies);
194
194
  }
195
195