npm.io
0.0.13 • Published 2 years ago

@cystain/novu-rest-js

Licence
MIT
Version
0.0.13
Deps
1
Size
14 kB
Vulns
0
Weekly
0

Novu Rest Client for JS

A third-party library for invoking the REST APIs of Novu

(still a work-in-progress)

Motivation

This is an open-source project that aims to provide wider compatibility to other non-node JS runtime.

Use case(s)

  • Use on cloudflare workers - Since cloudflare workers do not natively run on Node runtime, @novu/node is not usable, mostly due to its use of axios. To solve this, we use fetch() for performing requests.

Install as dependency

npm i @cystain/novu-rest-js

Usage

import { NovuRestClient } from '@cystain/novu-rest-js/lib/restClient';

const novuRestClient = new NovuRestClient('<YOUR_NOVU_API_KEY>');

// Sample trigger request (Trigger Event)
await novuRestClient.trigger('<WORKFLOW_TRIGGER_ID>', {
  to: {
    subscriberId: '<SUBSCRIBER_ID>',
  },
  payload: {
    title: 'Notif title',
    body: 'Notif body',
    link: 'http://example.com',
  },
  overrides: {
    fcm: {
      type: 'data',
    },
  },
});

For the request specifications, refer to the REST API doc: https://docs.novu.co/api-reference/events/trigger-event