@middy/cloudwatch-metrics 6.1.5 → 6.2.0

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 (3) hide show
  1. package/index.d.ts +12 -12
  2. package/index.js +30 -30
  3. package/package.json +71 -74
package/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import middy from '@middy/core'
2
- import { MetricsLogger } from 'aws-embedded-metrics'
3
- import type { Context as LambdaContext } from 'aws-lambda'
4
- export { MetricsLogger } from 'aws-embedded-metrics'
1
+ import type middy from "@middy/core";
2
+ import type { MetricsLogger } from "aws-embedded-metrics";
3
+ import type { Context as LambdaContext } from "aws-lambda";
4
+ export { MetricsLogger } from "aws-embedded-metrics";
5
5
 
6
6
  interface Options {
7
- namespace?: string
8
- dimensions?: Array<Record<string, string>>
7
+ namespace?: string;
8
+ dimensions?: Array<Record<string, string>>;
9
9
  }
10
10
 
11
11
  export type Context = LambdaContext & {
12
- metrics: MetricsLogger
13
- }
12
+ metrics: MetricsLogger;
13
+ };
14
14
 
15
- declare function cloudwatchMetrics (
16
- options?: Options
17
- ): middy.MiddlewareObj<unknown, any, Error, Context>
15
+ declare function cloudwatchMetrics(
16
+ options?: Options,
17
+ ): middy.MiddlewareObj<unknown, any, Error, Context>;
18
18
 
19
- export default cloudwatchMetrics
19
+ export default cloudwatchMetrics;
package/index.js CHANGED
@@ -1,38 +1,38 @@
1
- import awsEmbeddedMetrics from 'aws-embedded-metrics'
1
+ import awsEmbeddedMetrics from "aws-embedded-metrics";
2
2
 
3
- const defaults = {}
3
+ const defaults = {};
4
4
 
5
5
  const cloudwatchMetricsMiddleware = (opts = {}) => {
6
- const { namespace, dimensions } = { ...defaults, ...opts }
7
- const cloudwatchMetricsBefore = (request) => {
8
- const metrics = awsEmbeddedMetrics.createMetricsLogger()
6
+ const { namespace, dimensions } = { ...defaults, ...opts };
7
+ const cloudwatchMetricsBefore = (request) => {
8
+ const metrics = awsEmbeddedMetrics.createMetricsLogger();
9
9
 
10
- // If not set, defaults to aws-embedded-metrics
11
- if (namespace) {
12
- metrics.setNamespace(namespace)
13
- }
10
+ // If not set, defaults to aws-embedded-metrics
11
+ if (namespace) {
12
+ metrics.setNamespace(namespace);
13
+ }
14
14
 
15
- // If not set, keeps defaults as defined here https://github.com/awslabs/aws-embedded-metrics-node/#configuration
16
- if (dimensions) {
17
- metrics.setDimensions(dimensions)
18
- }
19
- Object.assign(request.context, { metrics })
20
- }
15
+ // If not set, keeps defaults as defined here https://github.com/awslabs/aws-embedded-metrics-node/#configuration
16
+ if (dimensions) {
17
+ metrics.setDimensions(dimensions);
18
+ }
19
+ Object.assign(request.context, { metrics });
20
+ };
21
21
 
22
- const cloudwatchMetricsAfter = async (request) => {
23
- await request.context.metrics.flush()
24
- }
25
- const cloudwatchMetricsOnError = async (request) => {
26
- try {
27
- await cloudwatchMetricsAfter(request)
28
- } catch (e) {}
29
- }
22
+ const cloudwatchMetricsAfter = async (request) => {
23
+ await request.context.metrics.flush();
24
+ };
25
+ const cloudwatchMetricsOnError = async (request) => {
26
+ try {
27
+ await cloudwatchMetricsAfter(request);
28
+ } catch (e) {}
29
+ };
30
30
 
31
- return {
32
- before: cloudwatchMetricsBefore,
33
- after: cloudwatchMetricsAfter,
34
- onError: cloudwatchMetricsOnError
35
- }
36
- }
31
+ return {
32
+ before: cloudwatchMetricsBefore,
33
+ after: cloudwatchMetricsAfter,
34
+ onError: cloudwatchMetricsOnError,
35
+ };
36
+ };
37
37
 
38
- export default cloudwatchMetricsMiddleware
38
+ export default cloudwatchMetricsMiddleware;
package/package.json CHANGED
@@ -1,76 +1,73 @@
1
1
  {
2
- "name": "@middy/cloudwatch-metrics",
3
- "version": "6.1.5",
4
- "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
- "type": "module",
6
- "engines": {
7
- "node": ">=14"
8
- },
9
- "engineStrict": true,
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "module": "./index.js",
14
- "exports": {
15
- ".": {
16
- "import": {
17
- "types": "./index.d.ts",
18
- "default": "./index.js"
19
- },
20
- "require": {
21
- "default": "./index.js"
22
- }
23
- }
24
- },
25
- "types": "index.d.ts",
26
- "files": [
27
- "index.js",
28
- "index.d.ts"
29
- ],
30
- "scripts": {
31
- "test": "npm run test:unit && npm run test:fuzz",
32
- "test:unit": "node --test __tests__/index.js",
33
- "test:fuzz": "node --test __tests__/fuzz.js",
34
- "test:benchmark": "node __benchmarks__/index.js"
35
- },
36
- "license": "MIT",
37
- "keywords": [
38
- "Lambda",
39
- "Middleware",
40
- "Serverless",
41
- "Framework",
42
- "AWS",
43
- "AWS Lambda",
44
- "Middy",
45
- "HTTP",
46
- "API",
47
- "Metrics",
48
- "Custom Metrics",
49
- "Embedded Metrics",
50
- "CloudWatch"
51
- ],
52
- "author": {
53
- "name": "Middy contributors",
54
- "url": "https://github.com/middyjs/middy/graphs/contributors"
55
- },
56
- "repository": {
57
- "type": "git",
58
- "url": "git+https://github.com/middyjs/middy.git",
59
- "directory": "packages/cloudwatch-metrics"
60
- },
61
- "bugs": {
62
- "url": "https://github.com/middyjs/middy/issues"
63
- },
64
- "homepage": "https://middy.js.org",
65
- "funding": {
66
- "type": "github",
67
- "url": "https://github.com/sponsors/willfarrell"
68
- },
69
- "dependencies": {
70
- "aws-embedded-metrics": "4.2.0"
71
- },
72
- "devDependencies": {
73
- "@types/aws-lambda": "^8.10.101"
74
- },
75
- "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
2
+ "name": "@middy/cloudwatch-metrics",
3
+ "version": "6.2.0",
4
+ "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=14"
8
+ },
9
+ "engineStrict": true,
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "module": "./index.js",
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./index.d.ts",
18
+ "default": "./index.js"
19
+ },
20
+ "require": {
21
+ "default": "./index.js"
22
+ }
23
+ }
24
+ },
25
+ "types": "index.d.ts",
26
+ "files": ["index.js", "index.d.ts"],
27
+ "scripts": {
28
+ "test": "npm run test:unit && npm run test:fuzz",
29
+ "test:unit": "node --test",
30
+ "test:fuzz": "node --test index.fuzz.js",
31
+ "test:perf": "node --test index.perf.js"
32
+ },
33
+ "license": "MIT",
34
+ "keywords": [
35
+ "Lambda",
36
+ "Middleware",
37
+ "Serverless",
38
+ "Framework",
39
+ "AWS",
40
+ "AWS Lambda",
41
+ "Middy",
42
+ "HTTP",
43
+ "API",
44
+ "Metrics",
45
+ "Custom Metrics",
46
+ "Embedded Metrics",
47
+ "CloudWatch"
48
+ ],
49
+ "author": {
50
+ "name": "Middy contributors",
51
+ "url": "https://github.com/middyjs/middy/graphs/contributors"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/middyjs/middy.git",
56
+ "directory": "packages/cloudwatch-metrics"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/middyjs/middy/issues"
60
+ },
61
+ "homepage": "https://middy.js.org",
62
+ "funding": {
63
+ "type": "github",
64
+ "url": "https://github.com/sponsors/willfarrell"
65
+ },
66
+ "dependencies": {
67
+ "aws-embedded-metrics": "4.2.0"
68
+ },
69
+ "devDependencies": {
70
+ "@types/aws-lambda": "^8.10.101"
71
+ },
72
+ "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
76
73
  }