Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
amp-api
Advanced tools
Readme
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
const AmpApi = require('amp-api');
const ampApi = new AmpApi({
// api key from google developer console
apiKey: 'keyfromgooglecosole',
// a logger that has info, warn, error, and fatal (defaults to console)
log: logger,
// path on your file system to your private key
keyPath: '/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.
FAQs
Warm/Bust/Validate Amp Cache
The npm package amp-api receives a total of 9 weekly downloads. As such, amp-api popularity was classified as not popular.
We found that amp-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.