@middy/appconfig 7.1.2 → 7.1.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/README.md +17 -0
- package/index.d.ts +1 -1
- package/index.js +7 -6
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -30,6 +30,23 @@
|
|
|
30
30
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/appconfig">https://middy.js.org/docs/middlewares/appconfig</a></p>
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install --save @middy/appconfig @aws-sdk/client-appconfigdata
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Documentation and examples
|
|
41
|
+
|
|
42
|
+
For documentation and examples, refer to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org/docs/middlewares/appconfig).
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Contributing
|
|
46
|
+
|
|
47
|
+
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
|
|
48
|
+
|
|
49
|
+
|
|
33
50
|
## License
|
|
34
51
|
|
|
35
52
|
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2026 [will Farrell](https://github.com/willfarrell), [Luciano Mammino](https://github.com/lmammino), and [Middy contributors](https://github.com/middyjs/middy/graphs/contributors).
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -29,7 +29,7 @@ const defaults = {
|
|
|
29
29
|
cacheExpiry: -1,
|
|
30
30
|
setToContext: false,
|
|
31
31
|
};
|
|
32
|
-
const
|
|
32
|
+
const jsonContentTypePattern = /^application\/([a-z0-9.+-]+\+)?json(;|$)/i;
|
|
33
33
|
const appConfigMiddleware = (opts = {}) => {
|
|
34
34
|
const options = {
|
|
35
35
|
...defaults,
|
|
@@ -54,7 +54,7 @@ const appConfigMiddleware = (opts = {}) => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
let value = new TextDecoder().decode(configResp.Configuration);
|
|
57
|
-
if (
|
|
57
|
+
if (jsonContentTypePattern.test(configResp.ContentType)) {
|
|
58
58
|
value = jsonSafeParse(value);
|
|
59
59
|
}
|
|
60
60
|
configurationCache[internalKey] = value;
|
|
@@ -68,11 +68,12 @@ const appConfigMiddleware = (opts = {}) => {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
const fetchDataKeys = Object.keys(options.fetchData);
|
|
71
72
|
const fetchRequest = (request, cachedValues = {}) => {
|
|
72
73
|
const values = {};
|
|
73
|
-
for (const internalKey of
|
|
74
|
+
for (const internalKey of fetchDataKeys) {
|
|
74
75
|
if (cachedValues[internalKey]) continue;
|
|
75
|
-
if (configurationTokenCache[internalKey]
|
|
76
|
+
if (typeof configurationTokenCache[internalKey] === "undefined") {
|
|
76
77
|
const command = new StartConfigurationSessionCommand(
|
|
77
78
|
options.fetchData[internalKey],
|
|
78
79
|
);
|
|
@@ -86,7 +87,7 @@ const appConfigMiddleware = (opts = {}) => {
|
|
|
86
87
|
),
|
|
87
88
|
)
|
|
88
89
|
.catch((e) => {
|
|
89
|
-
const value = getCache(options.cacheKey).value
|
|
90
|
+
const value = { ...getCache(options.cacheKey).value };
|
|
90
91
|
value[internalKey] = undefined;
|
|
91
92
|
modifyCache(options.cacheKey, value);
|
|
92
93
|
throw e;
|
|
@@ -113,7 +114,7 @@ const appConfigMiddleware = (opts = {}) => {
|
|
|
113
114
|
const { value } = processCache(options, fetchRequest, request);
|
|
114
115
|
Object.assign(request.internal, value);
|
|
115
116
|
if (options.setToContext) {
|
|
116
|
-
const data = await getInternal(
|
|
117
|
+
const data = await getInternal(fetchDataKeys, request);
|
|
117
118
|
Object.assign(request.context, data);
|
|
118
119
|
}
|
|
119
120
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/appconfig",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.3",
|
|
4
4
|
"description": "AppConfig middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -70,14 +70,14 @@
|
|
|
70
70
|
"optional": true
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@middy/util": "7.1.3"
|
|
75
|
+
},
|
|
73
76
|
"devDependencies": {
|
|
74
77
|
"@aws-sdk/client-appconfigdata": "^3.0.0",
|
|
75
|
-
"@middy/core": "7.1.
|
|
78
|
+
"@middy/core": "7.1.3",
|
|
76
79
|
"@types/aws-lambda": "^8.0.0",
|
|
80
|
+
"@types/node": "^22.0.0",
|
|
77
81
|
"aws-xray-sdk": "^3.3.3"
|
|
78
|
-
}
|
|
79
|
-
"dependencies": {
|
|
80
|
-
"@middy/util": "7.1.2"
|
|
81
|
-
},
|
|
82
|
-
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
|
|
82
|
+
}
|
|
83
83
|
}
|