@middy/util
Advanced tools
Comparing version 3.6.2 to 4.0.0-alpha.0
import middy from '@middy/core' | ||
interface Options<Client, ClientOptions> { | ||
AwsClient?: new() => Client | ||
AwsClient?: new(...args: any[]) => Client | ||
awsClientOptions?: Partial<ClientOptions> | ||
@@ -6,0 +6,0 @@ awsClientAssumeRole?: string |
30
index.js
@@ -1,16 +0,3 @@ | ||
var _response; | ||
import { Agent } from 'https'; | ||
export const awsClientDefaultOptions = { | ||
httpOptions: { | ||
agent: new Agent({ | ||
keepAlive: true, | ||
secureProtocol: 'TLSv1_2_method' | ||
}) | ||
} | ||
}; | ||
export const createPrefetchClient = (options)=>{ | ||
const awsClientOptions = { | ||
...awsClientDefaultOptions, | ||
...options.awsClientOptions | ||
}; | ||
const { awsClientOptions } = options; | ||
const client = new options.AwsClient(awsClientOptions); | ||
@@ -75,5 +62,5 @@ if (options.awsClientCapture && options.disablePrefetch) { | ||
if (errors.length) { | ||
const error = new Error('Failed to resolve internal values'); | ||
error.cause = errors; | ||
throw error; | ||
throw new Error('Failed to resolve internal values', { | ||
cause: errors | ||
}); | ||
} | ||
@@ -181,6 +168,8 @@ return keys.reduce((obj, key, index)=>({ | ||
response = { | ||
statusCode: 200, | ||
body: response | ||
}; | ||
} | ||
(_response = response).headers ?? (_response.headers = {}); | ||
response.statusCode ??= 500; | ||
response.headers ??= {}; | ||
request.response = response; | ||
@@ -196,5 +185,4 @@ return response; | ||
} | ||
message ?? (message = httpErrorCodes[code]); | ||
super(message); | ||
this.cause = options.cause; | ||
message ??= httpErrorCodes[code]; | ||
super(message, options); | ||
const name = httpErrorCodes[code].replace(createErrorRegexp, ''); | ||
@@ -201,0 +189,0 @@ this.name = name.substr(-5) !== 'Error' ? name + 'Error' : name; |
{ | ||
"name": "@middy/util", | ||
"version": "3.6.2", | ||
"version": "4.0.0-alpha.0", | ||
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (util package)", | ||
"type": "module", | ||
"engines": { | ||
"node": ">=14" | ||
"node": ">=16" | ||
}, | ||
@@ -63,10 +63,10 @@ "engineStrict": true, | ||
"devDependencies": { | ||
"@middy/core": "3.6.2", | ||
"@aws-sdk/client-ssm": "^3.0.0", | ||
"@middy/core": "4.0.0-alpha.0", | ||
"@types/aws-lambda": "^8.10.76", | ||
"@types/node": "^18.0.0", | ||
"aws-sdk": "^2.939.0", | ||
"aws-xray-sdk": "^3.3.3" | ||
}, | ||
"homepage": "https://middy.js.org", | ||
"gitHead": "4c5d64c72dd4bfde0d3b828a0082c99f688c759c" | ||
"gitHead": "306fb9aa633d5757d11ced3dc192f046ef3c2685" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
6
25118
575
1
0
27