4.1.0 • Published 11 months ago

@financial-times/n-fastly-purger v4.1.0

Weekly downloads
23
License
ISC
Repository
github
Last release
11 months ago

n-fastly-purger

Lightweight, asynchronous Fastly purger.

npm i -P @financial-times/n-fastly-purger

Usage

import FastlyPurger from '@financial-times/n-fastly-purger';

const Fastly = new FastlyPurger({
    serviceId: 'fastlyServiceId',
    fastlyKey: 'fastlyAPIKey',
    timeout: 1000, // optional
    agent: new Agent({ keepAlive: true }), // optional; https agent
    silentMode: true, // optional; defaults to false
    loggerFn: sandbox.stub(), // optional
    logLevel: 'all' // optional; defaults to 'errors'
});

Options

Silent mode

  • silentMode: true: silent failure on purge error and boolean responses
  • silentMode: false: throw errors for failed purges; return JSON response from Fastly (status: ok and purge ID)

Logging

  • logLevel: 'errors': only log purge errors (default)
  • logLevel: 'all': log successful purges and purge errors
Logger function

A function to output logs; e.g.:

import logger from '@financial-times/n-logger'; 
// or n-serverless-logger

const Fastly = new FastlyPurger({ ...
    loggerFn: logger.error
});

Methods

Fastly.purgeKey('my-surrogate-key'); // purge a single key
Fastly.purgeKeys(['key-1', 'key-2']); // purge multiple surrogate keys
Fastly.purgeAll(); // purge the entire service
Fastly.purgeUrl('https://foo.com/bar'); // purge a single URL
4.1.0

11 months ago

4.0.0

1 year ago

3.0.0

2 years ago

2.0.0

4 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago