- Notifications
You must be signed in to change notification settings - Fork0
fastcompany/node-amp-api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
node-amp-api
is a node library that loads content into amp, updates amp cache, and validates urls against amp.
npm i amp-api --save --save-exact
Create an instance of AmpApi
constAmpApi=require('amp-api');constampApi=newAmpApi({// 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.validateAmpUrl('https://fastcompany.com/40467645/how-pie-became-a-powerful-punchline-in-political-provocation')
Batch Get Urls to Load in Amp, returns Promise
ampApi.batchGet({lookupStrategy:'FETCH_LIVE_DOC',urls:['https://amp.fastcompany.com/40491026/james-corden-lives-in-the-moment-heres-how']})
Update google's cache, returns Promise
ampApi.updateCache('https://amp.fastcompany.com/40491026/james-corden-lives-in-the-moment-heres-how')
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.
About
Lib to work with amp. Cache Busting / Warming / Validating
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.