node-amp-api
node-amp-api
is a node library that loads content into amp, updates amp cache, and validates urls against amp.
Contents
Installation
npm i amp-api --save --save-exact
Usage
Create an instance of AmpApi
const AmpApi = ;const ampApi =// api key from google developer consoleapiKey: 'keyfromgooglecosole'// a logger that has info, warn, error, and fatal (defaults to console)log: logger// path on your file system to your private keykeyPath: '/path-to/file-system/private-key.pem';
Validate a url, returns Promise
ampApi
Batch Get Urls to Load in Amp, returns Promise
ampApi
Update google's cache, returns Promise
ampApi
Contributing
Open an issue.
Get an api key:
https://console.developers.google.com/apis/dashboard
Follow google's directions on hosting the public key:
https://developers.google.com/amp/cache/update-cache
Example here:
https://www.fastcompany.com/.well-known/amphtml/apikey.pub
Update local .env.
Code, test, make a PR, reference the issue.