apify-retainer
v0.1.6
Published
A utility for charging retainer fees in Apify actors
Maintainers
Readme
Apify Retainer
A utility package for charging retainer fees in Apify actors. Uses custom Supabase endpoint to charge the retainer fee.
Installation
npm install apify-retainerYou can also add it directly to your package.json:
"dependencies": {
"apify-retainer": "^0.1.0"
}Then run:
npm installUsage
import { Actor } from "apify";
import { chargeRetainerFee } from "apify-retainer";
// Initialize Apify Actor
await Actor.init();
// Environment variables should be set in your Apify actor configuration:
// - RETAINER_CHARGE_URL: The URL endpoint for checking if a charge should be made
// - RETAINER_CHARGE_KEY: The API key for authenticating with the charge endpoint
// - RETAINER_EVENT_NAME: (Optional) The name of the event for charging (default: 'retainer')
// Charge retainer fee
const result = await chargeRetainerFee();
if (result?.ok) {
console.log("Retainer fee charged successfully");
} else if (result) {
console.log(`Retainer fee already charged at: ${result.last_charged_at}`);
} else {
console.log("Retainer fee charge not applicable");
}
// Exit the Actor
await Actor.exit();API
chargeRetainerFee()
Charges a retainer fee for an Apify actor.
Environment Variables
RETAINER_CHARGE_URL(required): The URL endpoint for checking if a charge should be madeRETAINER_CHARGE_KEY(required): The API key for authenticating with the charge endpointRETAINER_EVENT_NAME(optional): The name of the event for charging (default: 'retainer')
Returns
- Promise that resolves to:
{ ok: true }if charge was successful{ ok: false, last_charged_at: string }if already chargednullif charging is not applicable
Requirements
- Node.js 18 or later
- Apify SDK 3.0.0 or later
Publishing
This package is published to the npm registry. The publishing process is automated using GitHub Actions.
To publish a new version:
- Update the version in
package.json - Push changes to the main branch
- The GitHub Actions workflow will automatically:
- Create a new tag based on the version in package.json
- Build the package
- Publish to npm
License
ISC
