@middy/warmup 3.0.0-alpha.6 → 3.0.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.
- package/README.md +23 -16
- package/index.cjs +3 -0
- package/index.js +2 -20
- package/package.json +12 -5
package/README.md
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
|
-
# Middy warmup middleware
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
<img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/master/img/middy-logo.png"/>
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
1
|
<div align="center">
|
|
2
|
+
<h1>Middy warmup middleware</h1>
|
|
3
|
+
<img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/img/middy-logo.svg"/>
|
|
8
4
|
<p><strong>Warmup middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda</strong></p>
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<div align="center">
|
|
12
5
|
<p>
|
|
13
|
-
<a href="
|
|
6
|
+
<a href="https://www.npmjs.com/package/@middy/warmup?activeTab=versions">
|
|
14
7
|
<img src="https://badge.fury.io/js/%40middy%2Fwarmup.svg" alt="npm version" style="max-width:100%;">
|
|
15
8
|
</a>
|
|
9
|
+
<a href="https://packagephobia.com/result?p=@middy/warmup">
|
|
10
|
+
<img src="https://packagephobia.com/badge?p=@middy/warmup" alt="npm install size" style="max-width:100%;">
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://github.com/middyjs/middy/actions">
|
|
13
|
+
<img src="https://github.com/middyjs/middy/workflows/Tests/badge.svg" alt="GitHub Actions test status badge" style="max-width:100%;">
|
|
14
|
+
</a>
|
|
15
|
+
<br/>
|
|
16
|
+
<a href="https://standardjs.com/">
|
|
17
|
+
<img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard Code Style" style="max-width:100%;">
|
|
18
|
+
</a>
|
|
16
19
|
<a href="https://snyk.io/test/github/middyjs/middy">
|
|
17
20
|
<img src="https://snyk.io/test/github/middyjs/middy/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/middyjs/middy" style="max-width:100%;">
|
|
18
21
|
</a>
|
|
19
|
-
<a href="https://
|
|
20
|
-
<img src="https://img.shields.io/
|
|
22
|
+
<a href="https://lgtm.com/projects/g/middyjs/middy/context:javascript">
|
|
23
|
+
<img src="https://img.shields.io/lgtm/grade/javascript/g/middyjs/middy.svg?logo=lgtm&logoWidth=18" alt="Language grade: JavaScript" style="max-width:100%;">
|
|
21
24
|
</a>
|
|
22
|
-
<a href="https://
|
|
23
|
-
<img src="https://
|
|
25
|
+
<a href="https://bestpractices.coreinfrastructure.org/projects/5280">
|
|
26
|
+
<img src="https://bestpractices.coreinfrastructure.org/projects/5280/badge" alt="Core Infrastructure Initiative (CII) Best Practices" style="max-width:100%;">
|
|
24
27
|
</a>
|
|
28
|
+
<br/>
|
|
25
29
|
<a href="https://gitter.im/middyjs/Lobby">
|
|
26
|
-
<img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter"
|
|
30
|
+
<img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;">
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://stackoverflow.com/questions/tagged/middy?sort=Newest&uqlId=35052">
|
|
33
|
+
<img src="https://img.shields.io/badge/StackOverflow-[middy]-yellow" alt="Ask questions on StackOverflow" style="max-width:100%;">
|
|
27
34
|
</a>
|
|
28
35
|
</p>
|
|
29
36
|
</div>
|
|
@@ -52,7 +59,7 @@ npm install --save @middy/warmup
|
|
|
52
59
|
|
|
53
60
|
## Options
|
|
54
61
|
|
|
55
|
-
- `isWarmingUp`: a function that accepts the `event` object as a parameter
|
|
62
|
+
- `isWarmingUp`: (function) a function that accepts the `event` object as a parameter
|
|
56
63
|
and returns `true` if the current event is a warmup event and `false` if it's a regular execution. The default function will check if the `event` object has a `source` property set to `serverless-plugin-warmup`.
|
|
57
64
|
|
|
58
65
|
## Sample usage
|
package/index.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;const defaults={isWarmingUp:event=>event.source==="serverless-plugin-warmup"};const warmupMiddleware=opt=>{const options={...defaults,...opt};const warmupMiddlewareBefore=request=>{if(options.isWarmingUp(request.event)){return"warmup"}};return{before:warmupMiddlewareBefore}};var _default=warmupMiddleware;exports.default=_default
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
const defaults = {
|
|
2
|
-
isWarmingUp: event => event.source === 'serverless-plugin-warmup'
|
|
3
|
-
};
|
|
1
|
+
const defaults={isWarmingUp:event=>event.source==="serverless-plugin-warmup"};const warmupMiddleware=opt=>{const options={...defaults,...opt};const warmupMiddlewareBefore=request=>{if(options.isWarmingUp(request.event)){return"warmup"}};return{before:warmupMiddlewareBefore}};export default warmupMiddleware
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
const options = { ...defaults,
|
|
7
|
-
...opt
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const warmupMiddlewareBefore = request => {
|
|
11
|
-
if (options.isWarmingUp(request.event)) {
|
|
12
|
-
return 'warmup';
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
before: warmupMiddlewareBefore
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default warmupMiddleware;
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/warmup",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Warmup (cold start mitigation) middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -10,10 +10,17 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"exports":
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./index.js",
|
|
16
|
+
"require": "./index.cjs",
|
|
17
|
+
"types": "./index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
14
20
|
"types": "index.d.ts",
|
|
15
21
|
"files": [
|
|
16
22
|
"index.js",
|
|
23
|
+
"index.cjs",
|
|
17
24
|
"index.d.ts"
|
|
18
25
|
],
|
|
19
26
|
"scripts": {
|
|
@@ -46,9 +53,9 @@
|
|
|
46
53
|
"bugs": {
|
|
47
54
|
"url": "https://github.com/middyjs/middy/issues"
|
|
48
55
|
},
|
|
49
|
-
"homepage": "https://
|
|
56
|
+
"homepage": "https://middy.js.org",
|
|
50
57
|
"devDependencies": {
|
|
51
|
-
"@middy/core": "^3.0.0
|
|
58
|
+
"@middy/core": "^3.0.0"
|
|
52
59
|
},
|
|
53
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "01520fa8628a36c2f89e126cad656a16547ea0d6"
|
|
54
61
|
}
|