| 16 | const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) |
| 17 | |
| 18 | async function purgeFastlyBySurrogateKey({ apiToken, serviceId, surrogateKey }) { |
| 19 | const safeServiceId = encodeURIComponent(serviceId) |
| 20 | |
| 21 | const headers = { |
| 22 | 'fastly-key': apiToken, |
| 23 | accept: 'application/json', |
| 24 | 'fastly-soft-purge': '1', |
| 25 | } |
| 26 | const requestPath = `https://api.fastly.com/service/${safeServiceId}/purge/${surrogateKey}` |
| 27 | return got.post(requestPath, { headers, json: true }) |
| 28 | } |
| 29 | |
| 30 | export default async function purgeEdgeCache( |
| 31 | surrogateKey, |