UNPKG

383 BJavaScriptView Raw
1const defaults = {
2 isWarmingUp: (event) => event.source === 'serverless-plugin-warmup'
3}
4
5const 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
19export default warmupMiddleware