hookpulse
v1.0.1
Published
Official JavaScript/TypeScript SDK for HookPulse - Enterprise-grade serverless task scheduling and webhook orchestration
Maintainers
Readme
HookPulse JavaScript/TypeScript SDK
Official JavaScript/TypeScript SDK for HookPulse - the enterprise-grade serverless task scheduling and webhook orchestration platform. Built with Elixir/OTP for 99.9% uptime.
Installation
npm install hookpulse
# or
yarn add hookpulse
# or
pnpm add hookpulseQuick Start
import { HookPulseClient } from 'hookpulse';
// Initialize the client
const client = new HookPulseClient({
apiKey: 'your-api-key',
brandUuid: 'your-brand-uuid'
});
// Create an interval schedule (every hour)
const schedule = await client.createSchedule({
webhookUrl: 'https://example.com/webhook',
scheduleType: 'interval',
intervalSeconds: 3600
});
// Create a cron schedule (daily at 9 AM)
const schedule = await client.createSchedule({
webhookUrl: 'https://example.com/webhook',
scheduleType: 'cron',
cronExpression: '0 9 * * *',
timezone: 'America/New_York'
});Configuration
Default Configuration
By default, the SDK uses https://api.hookpulse.io as the base URL. You can change this if needed:
const client = new HookPulseClient({
apiKey: 'your-api-key',
brandUuid: 'your-brand-uuid',
baseUrl: 'https://custom-api.example.com', // Optional
timeout: 60000 // Optional, default: 30000ms
});Authentication
The SDK requires two authentication headers:
x-hookpulse-api-key: Your API key (get from dashboard → API Keys)x-brand-uuid: Your brand UUID (get from dashboard after adding a brand)
Both are automatically included in all requests.
Features
Schedule Management
Interval Schedules
// Schedule every 5 minutes
await client.createSchedule({
webhookUrl: 'https://example.com/webhook',
scheduleType: 'interval',
intervalSeconds: 300
});Cron Schedules
// Daily at 9 AM
await client.createSchedule({
webhookUrl: 'https://example.com/webhook',
scheduleType: 'cron',
cronExpression: '0 9 * * *',
timezone: 'America/New_York'
});Clocked Schedules (One-time)
// Schedule for a specific date/time
await client.createSchedule({
webhookUrl: 'https://example.com/webhook',
scheduleType: 'clocked',
scheduledTime: '2024-12-25T09:00:00Z',
timezone: 'UTC'
});Webhook Templates
// Create a webhook template
const template = await client.createWebhookTemplate(
'Payment Notification',
'https://api.example.com/payments',
'POST',
{ 'Authorization': 'Bearer {{ #api_key }}' },
{ amount: '{{ amount }}', currency: 'USD' }
);
// Get all templates
const templates = await client.getWebhookTemplates(1);
// Update a template
await client.updateWebhookTemplate(template.data.uuid, {
name: 'Updated Payment Notification'
});Workflow Templates
// Create a workflow template
const workflow = await client.createWorkflowTemplate(
'Payment Processing',
[
{
name: 'Validate Payment',
type: 'webhook',
url: 'https://api.example.com/validate',
method: 'POST'
}
],
'fifo'
);Schedule Management
// Get all schedules
const schedules = await client.getSchedules(1, 'active');
// Get a specific schedule
const schedule = await client.getSchedule('uuid-here');
// Pause a schedule
await client.updateScheduleStatus('uuid-here', 'paused');
// Resume a schedule
await client.updateScheduleStatus('uuid-here', 'active');
// Delete a schedule
await client.deleteSchedule('uuid-here');Error Handling
import {
HookPulseClient,
HookPulseError,
HookPulseAPIError,
HookPulseAuthError
} from 'hookpulse';
try {
const client = new HookPulseClient({
apiKey: 'invalid',
brandUuid: 'invalid'
});
await client.createSchedule({...});
} catch (error) {
if (error instanceof HookPulseAuthError) {
console.error('Authentication failed:', error.message);
} else if (error instanceof HookPulseAPIError) {
console.error(`API error (${error.statusCode}):`, error.message);
} else if (error instanceof HookPulseError) {
console.error('Error:', error.message);
}
}TypeScript Support
This package includes full TypeScript definitions. No additional @types package needed.
Documentation
Requirements
- Node.js >= 14.0.0
- TypeScript >= 5.0.0 (optional, for TypeScript projects)
License
MIT License - see LICENSE file for details
Support
- Email: [email protected]
- Documentation: https://docs.hookpulse.io/docs
- Issues: Report an issue for the JavaScript/TypeScript SDK
- Source: hookpulse-js/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
