geonix 1.22.2 → 1.22.3
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 +1 -0
- package/package.json +1 -1
- package/src/Util.js +5 -1
- package/test/middleware.js +14 -16
package/index.d.ts
CHANGED
|
@@ -213,6 +213,7 @@ type ServiceOptions = {
|
|
|
213
213
|
export function parseURL(url: string): any;
|
|
214
214
|
export function getFirstItemFromAsyncIterable(asyncIterable: any): Promise<any>;
|
|
215
215
|
export function getNetworkAddresses(): any[];
|
|
216
|
+
export function isIterable(obj: any): any;
|
|
216
217
|
/**
|
|
217
218
|
*
|
|
218
219
|
*
|
package/package.json
CHANGED
package/src/Util.js
CHANGED
|
@@ -241,6 +241,10 @@ export function getNetworkAddresses() {
|
|
|
241
241
|
return list;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
export function isIterable(obj) {
|
|
245
|
+
return obj && (typeof obj[Symbol.iterator] === "function" || typeof obj[Symbol.asyncIterator] === "function");
|
|
246
|
+
}
|
|
247
|
+
|
|
244
248
|
/**
|
|
245
249
|
*
|
|
246
250
|
*
|
|
@@ -263,7 +267,7 @@ export async function parseMultipart(req, _options) {
|
|
|
263
267
|
let stream = req;
|
|
264
268
|
|
|
265
269
|
// if body is present, create a stream from it and use memory
|
|
266
|
-
if (req.body) {
|
|
270
|
+
if (req.body && isIterable(req.body)) {
|
|
267
271
|
stream = Readable.from(req.body);
|
|
268
272
|
options.useMemory = true;
|
|
269
273
|
}
|
package/test/middleware.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
1
2
|
import { ServeStatic, Service } from "../exports.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
function special(req, res) {
|
|
5
|
+
console.log("THIS:", this);
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
7
|
+
res.send(`Hello ${this.value}`);
|
|
8
|
+
};
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
class ApplicationService extends Service {
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
value = "World!";
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
res.end(JSON.stringify(req.cookies));
|
|
14
|
+
async onStart() {
|
|
15
15
|
}
|
|
16
|
-
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
"GET
|
|
20
|
-
|
|
21
|
-
}
|
|
17
|
+
"GET *" = [special, ServeStatic("test/static", { indexOn404: true })];
|
|
18
|
+
// "GET *" = [(req, res) => {
|
|
19
|
+
// res.send(`Hello ${this.value}`);
|
|
20
|
+
// }];
|
|
21
|
+
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
First.start({ middleware: { raw: true } });
|
|
26
|
-
Second.start();
|
|
24
|
+
ApplicationService.start();
|