@faasjs/http 0.0.3-beta.77 → 0.0.3-beta.79
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/dist/index.js +32 -84
- package/dist/index.mjs +32 -98
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
-
};
|
|
14
6
|
var __export = (target, all) => {
|
|
15
7
|
for (var name in all)
|
|
16
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,73 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
15
|
}
|
|
24
16
|
return to;
|
|
25
17
|
};
|
|
26
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
-
mod
|
|
29
|
-
));
|
|
30
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
19
|
|
|
32
|
-
// ../../node_modules/tsup/assets/cjs_shims.js
|
|
33
|
-
var init_cjs_shims = __esm({
|
|
34
|
-
"../../node_modules/tsup/assets/cjs_shims.js"() {
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// ../deep_merge/dist/index.js
|
|
39
|
-
var require_dist = __commonJS({
|
|
40
|
-
"../deep_merge/dist/index.js"(exports, module2) {
|
|
41
|
-
"use strict";
|
|
42
|
-
init_cjs_shims();
|
|
43
|
-
var __defProp2 = Object.defineProperty;
|
|
44
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
45
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
46
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
47
|
-
var __export2 = (target, all) => {
|
|
48
|
-
for (var name in all)
|
|
49
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
50
|
-
};
|
|
51
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
52
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
53
|
-
for (let key of __getOwnPropNames2(from))
|
|
54
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
55
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
56
|
-
}
|
|
57
|
-
return to;
|
|
58
|
-
};
|
|
59
|
-
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
60
|
-
var src_exports2 = {};
|
|
61
|
-
__export2(src_exports2, {
|
|
62
|
-
deepMerge: () => deepMerge3
|
|
63
|
-
});
|
|
64
|
-
module2.exports = __toCommonJS2(src_exports2);
|
|
65
|
-
var shouldMerge = function(item) {
|
|
66
|
-
const type = Object.prototype.toString.call(item);
|
|
67
|
-
return type === "[object Object]" || type === "[object Array]";
|
|
68
|
-
};
|
|
69
|
-
function deepMerge3(...sources) {
|
|
70
|
-
let acc = /* @__PURE__ */ Object.create(null);
|
|
71
|
-
for (const source of sources)
|
|
72
|
-
if (source instanceof Array) {
|
|
73
|
-
if (!(acc instanceof Array))
|
|
74
|
-
acc = [];
|
|
75
|
-
acc = [...new Set(source.concat(...acc))];
|
|
76
|
-
} else if (shouldMerge(source))
|
|
77
|
-
for (const [key, value] of Object.entries(source)) {
|
|
78
|
-
let val;
|
|
79
|
-
if (shouldMerge(value))
|
|
80
|
-
val = deepMerge3(acc[key], value);
|
|
81
|
-
else
|
|
82
|
-
val = value;
|
|
83
|
-
acc = {
|
|
84
|
-
...acc,
|
|
85
|
-
[key]: val
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return acc;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
20
|
// src/index.ts
|
|
94
21
|
var src_exports = {};
|
|
95
22
|
__export(src_exports, {
|
|
@@ -102,16 +29,39 @@ __export(src_exports, {
|
|
|
102
29
|
useHttp: () => useHttp
|
|
103
30
|
});
|
|
104
31
|
module.exports = __toCommonJS(src_exports);
|
|
105
|
-
init_cjs_shims();
|
|
106
32
|
var import_func = require("@faasjs/func");
|
|
107
|
-
var import_deep_merge2 = __toESM(require_dist());
|
|
108
|
-
var import_logger = require("@faasjs/logger");
|
|
109
33
|
|
|
110
|
-
// src/
|
|
111
|
-
|
|
34
|
+
// ../deep_merge/src/index.ts
|
|
35
|
+
var shouldMerge = function(item) {
|
|
36
|
+
const type = Object.prototype.toString.call(item);
|
|
37
|
+
return type === "[object Object]" || type === "[object Array]";
|
|
38
|
+
};
|
|
39
|
+
function deepMerge(...sources) {
|
|
40
|
+
let acc = /* @__PURE__ */ Object.create(null);
|
|
41
|
+
for (const source of sources)
|
|
42
|
+
if (source instanceof Array) {
|
|
43
|
+
if (!(acc instanceof Array))
|
|
44
|
+
acc = [];
|
|
45
|
+
acc = [...new Set(source.concat(...acc))];
|
|
46
|
+
} else if (shouldMerge(source))
|
|
47
|
+
for (const [key, value] of Object.entries(source)) {
|
|
48
|
+
let val;
|
|
49
|
+
if (shouldMerge(value))
|
|
50
|
+
val = deepMerge(acc[key], value);
|
|
51
|
+
else
|
|
52
|
+
val = value;
|
|
53
|
+
acc = {
|
|
54
|
+
...acc,
|
|
55
|
+
[key]: val
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return acc;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/index.ts
|
|
62
|
+
var import_logger = require("@faasjs/logger");
|
|
112
63
|
|
|
113
64
|
// src/session.ts
|
|
114
|
-
init_cjs_shims();
|
|
115
65
|
var import_crypto = require("crypto");
|
|
116
66
|
var Session = class {
|
|
117
67
|
constructor(cookie, config) {
|
|
@@ -202,10 +152,9 @@ var Session = class {
|
|
|
202
152
|
};
|
|
203
153
|
|
|
204
154
|
// src/cookie.ts
|
|
205
|
-
var import_deep_merge = __toESM(require_dist());
|
|
206
155
|
var Cookie = class {
|
|
207
156
|
constructor(config) {
|
|
208
|
-
this.config =
|
|
157
|
+
this.config = deepMerge({
|
|
209
158
|
path: "/",
|
|
210
159
|
expires: 31536e3,
|
|
211
160
|
secure: true,
|
|
@@ -268,7 +217,6 @@ var Cookie = class {
|
|
|
268
217
|
};
|
|
269
218
|
|
|
270
219
|
// src/validator.ts
|
|
271
|
-
init_cjs_shims();
|
|
272
220
|
var Validator = class {
|
|
273
221
|
constructor(config) {
|
|
274
222
|
this.paramsConfig = config.params;
|
|
@@ -492,7 +440,7 @@ var Http = class {
|
|
|
492
440
|
const logger = new import_logger.Logger(this.name);
|
|
493
441
|
logger.debug("Generate api gateway's config");
|
|
494
442
|
logger.debug("%j", data);
|
|
495
|
-
const config = data.config.plugins ?
|
|
443
|
+
const config = data.config.plugins ? deepMerge(data.config.plugins[this.name || this.type], { config: this.config }) : { config: this.config };
|
|
496
444
|
if (!config.config.path) {
|
|
497
445
|
config.config.path = "/" + ((_a = data.name) == null ? void 0 : _a.replace(/_/g, "/").replace(/\/index$/, ""));
|
|
498
446
|
if (config.config.path === "/index")
|
|
@@ -528,7 +476,7 @@ var Http = class {
|
|
|
528
476
|
this.config[key] = value;
|
|
529
477
|
}
|
|
530
478
|
if (data.config.plugins && data.config.plugins[this.name || this.type])
|
|
531
|
-
this.config =
|
|
479
|
+
this.config = deepMerge(this.config, data.config.plugins[this.name || this.type].config);
|
|
532
480
|
data.logger.debug("[onMount] prepare cookie & session");
|
|
533
481
|
this.cookie = new Cookie(this.config.cookie || {});
|
|
534
482
|
this.session = this.cookie.session;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
1
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
2
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
3
|
}) : x)(function(x) {
|
|
@@ -11,101 +5,43 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
11
5
|
return require.apply(this, arguments);
|
|
12
6
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
13
7
|
});
|
|
14
|
-
var __esm = (fn, res) => function __init() {
|
|
15
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
-
};
|
|
17
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
32
|
-
|
|
33
|
-
// ../../node_modules/tsup/assets/esm_shims.js
|
|
34
|
-
import { fileURLToPath } from "url";
|
|
35
|
-
import path from "path";
|
|
36
|
-
var init_esm_shims = __esm({
|
|
37
|
-
"../../node_modules/tsup/assets/esm_shims.js"() {
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// ../deep_merge/dist/index.js
|
|
42
|
-
var require_dist = __commonJS({
|
|
43
|
-
"../deep_merge/dist/index.js"(exports, module) {
|
|
44
|
-
"use strict";
|
|
45
|
-
init_esm_shims();
|
|
46
|
-
var __defProp2 = Object.defineProperty;
|
|
47
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
48
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
49
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
50
|
-
var __export = (target, all) => {
|
|
51
|
-
for (var name in all)
|
|
52
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
53
|
-
};
|
|
54
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
55
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
56
|
-
for (let key of __getOwnPropNames2(from))
|
|
57
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
58
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
59
|
-
}
|
|
60
|
-
return to;
|
|
61
|
-
};
|
|
62
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
63
|
-
var src_exports = {};
|
|
64
|
-
__export(src_exports, {
|
|
65
|
-
deepMerge: () => deepMerge3
|
|
66
|
-
});
|
|
67
|
-
module.exports = __toCommonJS(src_exports);
|
|
68
|
-
var shouldMerge = function(item) {
|
|
69
|
-
const type = Object.prototype.toString.call(item);
|
|
70
|
-
return type === "[object Object]" || type === "[object Array]";
|
|
71
|
-
};
|
|
72
|
-
function deepMerge3(...sources) {
|
|
73
|
-
let acc = /* @__PURE__ */ Object.create(null);
|
|
74
|
-
for (const source of sources)
|
|
75
|
-
if (source instanceof Array) {
|
|
76
|
-
if (!(acc instanceof Array))
|
|
77
|
-
acc = [];
|
|
78
|
-
acc = [...new Set(source.concat(...acc))];
|
|
79
|
-
} else if (shouldMerge(source))
|
|
80
|
-
for (const [key, value] of Object.entries(source)) {
|
|
81
|
-
let val;
|
|
82
|
-
if (shouldMerge(value))
|
|
83
|
-
val = deepMerge3(acc[key], value);
|
|
84
|
-
else
|
|
85
|
-
val = value;
|
|
86
|
-
acc = {
|
|
87
|
-
...acc,
|
|
88
|
-
[key]: val
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return acc;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
8
|
|
|
96
9
|
// src/index.ts
|
|
97
|
-
init_esm_shims();
|
|
98
|
-
var import_deep_merge2 = __toESM(require_dist());
|
|
99
10
|
import {
|
|
100
11
|
usePlugin
|
|
101
12
|
} from "@faasjs/func";
|
|
102
|
-
import { Logger } from "@faasjs/logger";
|
|
103
13
|
|
|
104
|
-
// src/
|
|
105
|
-
|
|
14
|
+
// ../deep_merge/src/index.ts
|
|
15
|
+
var shouldMerge = function(item) {
|
|
16
|
+
const type = Object.prototype.toString.call(item);
|
|
17
|
+
return type === "[object Object]" || type === "[object Array]";
|
|
18
|
+
};
|
|
19
|
+
function deepMerge(...sources) {
|
|
20
|
+
let acc = /* @__PURE__ */ Object.create(null);
|
|
21
|
+
for (const source of sources)
|
|
22
|
+
if (source instanceof Array) {
|
|
23
|
+
if (!(acc instanceof Array))
|
|
24
|
+
acc = [];
|
|
25
|
+
acc = [...new Set(source.concat(...acc))];
|
|
26
|
+
} else if (shouldMerge(source))
|
|
27
|
+
for (const [key, value] of Object.entries(source)) {
|
|
28
|
+
let val;
|
|
29
|
+
if (shouldMerge(value))
|
|
30
|
+
val = deepMerge(acc[key], value);
|
|
31
|
+
else
|
|
32
|
+
val = value;
|
|
33
|
+
acc = {
|
|
34
|
+
...acc,
|
|
35
|
+
[key]: val
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return acc;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/index.ts
|
|
42
|
+
import { Logger } from "@faasjs/logger";
|
|
106
43
|
|
|
107
44
|
// src/session.ts
|
|
108
|
-
init_esm_shims();
|
|
109
45
|
import {
|
|
110
46
|
randomBytes,
|
|
111
47
|
pbkdf2Sync,
|
|
@@ -202,10 +138,9 @@ var Session = class {
|
|
|
202
138
|
};
|
|
203
139
|
|
|
204
140
|
// src/cookie.ts
|
|
205
|
-
var import_deep_merge = __toESM(require_dist());
|
|
206
141
|
var Cookie = class {
|
|
207
142
|
constructor(config) {
|
|
208
|
-
this.config =
|
|
143
|
+
this.config = deepMerge({
|
|
209
144
|
path: "/",
|
|
210
145
|
expires: 31536e3,
|
|
211
146
|
secure: true,
|
|
@@ -268,7 +203,6 @@ var Cookie = class {
|
|
|
268
203
|
};
|
|
269
204
|
|
|
270
205
|
// src/validator.ts
|
|
271
|
-
init_esm_shims();
|
|
272
206
|
var Validator = class {
|
|
273
207
|
constructor(config) {
|
|
274
208
|
this.paramsConfig = config.params;
|
|
@@ -496,7 +430,7 @@ var Http = class {
|
|
|
496
430
|
const logger = new Logger(this.name);
|
|
497
431
|
logger.debug("Generate api gateway's config");
|
|
498
432
|
logger.debug("%j", data);
|
|
499
|
-
const config = data.config.plugins ?
|
|
433
|
+
const config = data.config.plugins ? deepMerge(data.config.plugins[this.name || this.type], { config: this.config }) : { config: this.config };
|
|
500
434
|
if (!config.config.path) {
|
|
501
435
|
config.config.path = "/" + ((_a = data.name) == null ? void 0 : _a.replace(/_/g, "/").replace(/\/index$/, ""));
|
|
502
436
|
if (config.config.path === "/index")
|
|
@@ -532,7 +466,7 @@ var Http = class {
|
|
|
532
466
|
this.config[key] = value;
|
|
533
467
|
}
|
|
534
468
|
if (data.config.plugins && data.config.plugins[this.name || this.type])
|
|
535
|
-
this.config =
|
|
469
|
+
this.config = deepMerge(this.config, data.config.plugins[this.name || this.type].config);
|
|
536
470
|
data.logger.debug("[onMount] prepare cookie & session");
|
|
537
471
|
this.cookie = new Cookie(this.config.cookie || {});
|
|
538
472
|
this.session = this.cookie.session;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/http",
|
|
3
|
-
"version": "0.0.3-beta.
|
|
3
|
+
"version": "0.0.3-beta.79",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@faasjs/func": "^0.0.3-beta.
|
|
26
|
-
"@faasjs/logger": "^0.0.3-beta.
|
|
25
|
+
"@faasjs/func": "^0.0.3-beta.79",
|
|
26
|
+
"@faasjs/logger": "^0.0.3-beta.79"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"npm": ">=8.0.0",
|