@middy/service-discovery 7.1.1 → 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 CHANGED
@@ -30,6 +30,23 @@
30
30
  <p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/service-discovery">https://middy.js.org/docs/middlewares/service-discovery</a></p>
31
31
  </div>
32
32
 
33
+ ## Install
34
+
35
+ ```bash
36
+ npm install --save @middy/service-discovery @aws-sdk/client-servicediscovery
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/service-discovery).
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
@@ -13,7 +13,7 @@ import type { Context as LambdaContext } from "aws-lambda";
13
13
  export type ParamType<T> = string & { __returnType?: T };
14
14
  export declare function serviceDiscoveryParam<T>(name: string): ParamType<T>;
15
15
 
16
- interface ServiceDiscoveryOptions<
16
+ export interface ServiceDiscoveryOptions<
17
17
  AwsServiceDiscoveryClient = ServiceDiscoveryClient,
18
18
  > extends Pick<
19
19
  MiddyOptions<AwsServiceDiscoveryClient, ServiceDiscoveryClientConfig>,
@@ -24,6 +24,7 @@ interface ServiceDiscoveryOptions<
24
24
  | "disablePrefetch"
25
25
  | "cacheKey"
26
26
  | "cacheExpiry"
27
+ | "cacheKeyExpiry"
27
28
  | "setToContext"
28
29
  > {
29
30
  fetchData?: { [key: string]: DiscoverInstancesCommandInput };
@@ -53,7 +54,7 @@ declare function serviceDiscovery<
53
54
  options?: TOptions,
54
55
  ): middy.MiddlewareObj<
55
56
  unknown,
56
- any,
57
+ unknown,
57
58
  Error,
58
59
  Context<TOptions>,
59
60
  Internal<TOptions>
package/index.js CHANGED
@@ -31,10 +31,11 @@ const defaults = {
31
31
  const serviceDiscoveryMiddleware = (opts = {}) => {
32
32
  const options = { ...defaults, ...opts };
33
33
 
34
+ const fetchDataKeys = Object.keys(options.fetchData);
34
35
  const fetchRequest = (request, cachedValues = {}) => {
35
36
  const values = {};
36
37
 
37
- for (const internalKey of Object.keys(options.fetchData)) {
38
+ for (const internalKey of fetchDataKeys) {
38
39
  if (cachedValues[internalKey]) continue;
39
40
 
40
41
  const command = new DiscoverInstancesCommand(
@@ -71,7 +72,7 @@ const serviceDiscoveryMiddleware = (opts = {}) => {
71
72
  Object.assign(request.internal, value);
72
73
 
73
74
  if (options.setToContext) {
74
- const data = await getInternal(Object.keys(options.fetchData), request);
75
+ const data = await getInternal(fetchDataKeys, request);
75
76
  Object.assign(request.context, data);
76
77
  }
77
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/service-discovery",
3
- "version": "7.1.1",
3
+ "version": "7.1.3",
4
4
  "description": "Service Discovery (Cloud Map) instances middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -73,13 +73,13 @@
73
73
  }
74
74
  },
75
75
  "dependencies": {
76
- "@middy/util": "7.1.1"
76
+ "@middy/util": "7.1.3"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@aws-sdk/client-servicediscovery": "^3.0.0",
80
- "@middy/core": "7.1.1",
80
+ "@middy/core": "7.1.3",
81
81
  "@types/aws-lambda": "^8.0.0",
82
+ "@types/node": "^22.0.0",
82
83
  "aws-xray-sdk": "^3.3.3"
83
- },
84
- "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
84
+ }
85
85
  }