1 | const defaults = {
|
2 | isWarmingUp: (event) => event.source === 'serverless-plugin-warmup'
|
3 | }
|
4 |
|
5 | const warmupMiddleware = (opt) => {
|
6 | const options = { ...defaults, ...opt }
|
7 |
|
8 | const warmupMiddlewareBefore = (request) => {
|
9 | if (options.isWarmingUp(request.event)) {
|
10 | return 'warmup'
|
11 | }
|
12 | }
|
13 |
|
14 | return {
|
15 | before: warmupMiddlewareBefore
|
16 | }
|
17 | }
|
18 |
|
19 | export default warmupMiddleware
|