@middy/cloudwatch-metrics 3.0.0-alpha.3 → 3.0.0-alpha.4

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.
Files changed (2) hide show
  1. package/index.js +20 -18
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -1,33 +1,35 @@
1
- import awsEmbeddedMetrics from 'aws-embedded-metrics'
2
-
3
- const defaults = {}
1
+ import awsEmbeddedMetrics from 'aws-embedded-metrics';
2
+ const defaults = {};
4
3
 
5
4
  const cloudwatchMetricsMiddleware = (opts = {}) => {
6
- const options = { ...defaults, ...opts }
5
+ const options = { ...defaults,
6
+ ...opts
7
+ };
7
8
 
8
- const cloudwatchMetricsBefore = (request) => {
9
- const metrics = awsEmbeddedMetrics.createMetricsLogger()
9
+ const cloudwatchMetricsBefore = request => {
10
+ const metrics = awsEmbeddedMetrics.createMetricsLogger();
10
11
 
11
- // If not set, defaults to aws-embedded-metrics
12
12
  if (options.namespace) {
13
- metrics.setNamespace(options.namespace)
13
+ metrics.setNamespace(options.namespace);
14
14
  }
15
15
 
16
- // If not set, defaults to ServiceName, ServiceType and LogGroupName
17
16
  if (options.dimensions) {
18
- metrics.setDimensions(...options.dimensions)
17
+ metrics.setDimensions(...options.dimensions);
19
18
  }
20
- Object.assign(request.context, { metrics })
21
- }
22
19
 
23
- const cloudwatchMetricsAfter = async (request) => {
24
- await request.context.metrics.flush()
25
- }
20
+ Object.assign(request.context, {
21
+ metrics
22
+ });
23
+ };
24
+
25
+ const cloudwatchMetricsAfter = async request => {
26
+ await request.context.metrics.flush();
27
+ };
26
28
 
27
29
  return {
28
30
  before: cloudwatchMetricsBefore,
29
31
  after: cloudwatchMetricsAfter
30
- }
31
- }
32
+ };
33
+ };
32
34
 
33
- export default cloudwatchMetricsMiddleware
35
+ export default cloudwatchMetricsMiddleware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/cloudwatch-metrics",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.4",
4
4
  "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -54,7 +54,7 @@
54
54
  "aws-embedded-metrics": "2.0.4"
55
55
  },
56
56
  "devDependencies": {
57
- "@middy/core": "^3.0.0-alpha.3"
57
+ "@middy/core": "^3.0.0-alpha.4"
58
58
  },
59
- "gitHead": "1441158711580313765e6d156046ef0fade0d156"
59
+ "gitHead": "d4bea7f4e21f6a9bbb1f6f6908361169598b9e53"
60
60
  }