1.1.1 • Published 4 years ago

adtoniq-express v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

npm.io

adtoniq-express

Adtoniq for Node.js implements the server-to-server communications required between your webserver and Adtoniq.

Install

npm i adtoniq-express

Usage

Get your API key.

const apiKey = "Your-API-Key-Here";

Initialize the API with your key.

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 functionality

Implement the following on every page handler where you want to integrate Adtoniq functionality.

adtoniq.getHeadCode({}, (headCode) => {
    // Inject headCode to the `<head>` section.
})

Process server refresh

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) => {
})

Process external cache refresh

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

License

This project is licensed under the MIT License

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.0

4 years ago