@middy/http-content-negotiation 2.5.2 → 3.0.0-alpha.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2021 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
3
+ Copyright (c) 2017-2022 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -117,7 +117,7 @@ handler
117
117
  }))
118
118
  .use(httpErrorHandler())
119
119
 
120
- module.exports = { handler }
120
+ export default { handler }
121
121
  ```
122
122
 
123
123
 
@@ -133,7 +133,7 @@ Everyone is very welcome to contribute to this repository. Feel free to [raise i
133
133
 
134
134
  ## License
135
135
 
136
- Licensed under [MIT License](LICENSE). Copyright (c) 2017-2021 Luciano Mammino, will Farrell, and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
136
+ Licensed under [MIT License](LICENSE). Copyright (c) 2017-2022 Luciano Mammino, will Farrell, and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
137
137
 
138
138
  <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
139
139
  <img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy.svg?type=large" alt="FOSSA Status" style="max-width:100%;">
package/index.js CHANGED
@@ -1,13 +1,8 @@
1
- "use strict";
2
-
3
- const charset = require('negotiator/lib/charset.js');
4
-
5
- const encoding = require('negotiator/lib/encoding.js');
6
-
7
- const language = require('negotiator/lib/language.js');
8
-
9
- const mediaType = require('negotiator/lib/mediaType.js');
10
-
1
+ import charset from 'negotiator/lib/charset.js';
2
+ import encoding from 'negotiator/lib/encoding.js';
3
+ import language from 'negotiator/lib/language.js';
4
+ import mediaType from 'negotiator/lib/mediaType.js';
5
+ import { createError } from '@middy/util';
11
6
  const parseFn = {
12
7
  Charset: charset,
13
8
  Encoding: encoding,
@@ -60,22 +55,15 @@ const httpContentNegotiationMiddleware = (opts = {}) => {
60
55
  };
61
56
 
62
57
  const parseHeader = (headerName, type, availableValues, failOnMismatch, event) => {
63
- var _event$headers$header;
64
-
65
58
  const resultsName = `preferred${type}s`;
66
59
  const resultName = `preferred${type}`;
67
- const headerValue = (_event$headers$header = event.headers[headerName]) !== null && _event$headers$header !== void 0 ? _event$headers$header : event.headers[headerName.toLowerCase()];
60
+ const headerValue = event.headers[headerName] ?? event.headers[headerName.toLowerCase()];
68
61
  event[resultsName] = parseFn[type](headerValue, availableValues);
69
62
  event[resultName] = event[resultsName][0];
70
63
 
71
64
  if (failOnMismatch && event[resultName] === undefined) {
72
- const {
73
- createError
74
- } = require('@middy/util'); // NotAcceptable
75
-
76
-
77
65
  throw createError(406, `Unsupported ${type}. Acceptable values: ${availableValues.join(', ')}`);
78
66
  }
79
67
  };
80
68
 
81
- module.exports = httpContentNegotiationMiddleware;
69
+ export default httpContentNegotiationMiddleware;
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@middy/http-content-negotiation",
3
- "version": "2.5.2",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "Http content negotiation middleware for the middy framework",
5
- "type": "commonjs",
5
+ "type": "module",
6
6
  "engines": {
7
- "node": ">=12"
7
+ "node": ">=14"
8
8
  },
9
9
  "engineStrict": true,
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "main": "index.js",
13
+ "exports": "./index.js",
14
14
  "types": "index.d.ts",
15
15
  "files": [
16
+ "index.js",
16
17
  "index.d.ts"
17
18
  ],
18
19
  "scripts": {
@@ -46,12 +47,11 @@
46
47
  },
47
48
  "homepage": "https://github.com/middyjs/middy#readme",
48
49
  "dependencies": {
49
- "@middy/util": "^2.5.2",
50
+ "@middy/util": "^3.0.0-alpha.1",
50
51
  "negotiator": "0.6.2"
51
52
  },
52
53
  "devDependencies": {
53
- "@middy/core": "^2.5.2",
54
- "http-errors": "^1.8.0"
54
+ "@middy/core": "^3.0.0-alpha.1"
55
55
  },
56
- "gitHead": "a2bb757a7a13638ae64277f8eecfcf11c1af17d4"
56
+ "gitHead": "a14125c6b2e21b181824f9985a919a47f1e4711f"
57
57
  }