Adtoniq for Node.js implements the server-to-server communications required between your webserver and Adtoniq.
npm i adtoniq-express
const apiKey = "Your-API-Key-Here";
const adtoniq = new Adtoniq(apiKey);
Optionaly, use this consructor to add functionality to manually update your cache / CDN when the JavaScript is updated. You will need to implement the following two functions and pass them to the constructor
saveScript = function(script, callback) {
// save script
callback()
}
loadScript = function(callback) {
callback(<saved script or null if none saved>)
}
const adtoniq = new Adtoniq(apiKey, saveScript, loadScript);
Implement the following on every page handler where you want to integrate Adtoniq functionality.
adtoniq.getHeadCode({}, (headCode) => {
// Inject headCode to the `<head>` section.
})
You must provide a handler for Adtoniq to transmit the latest JavaScript required to ensure Adtoniq continues functioning as new ad block rules are added, or ad blockers are enhanced with new capabilities. That handler will have to perform the following:
adtoniq.processRequest(request.body, (headCode) => {
})
When using exernal caching of the script and the cache is updated you must update adtoniq by calling:
adtoniq.setJavaScript(<updated script>)
For details and examples visit https://github.com/adtoniq/adtoniq-for-nodejs
This project is licensed under the MIT License