Skip to content

A tiny and easy-to-use package for sending notifications to Alwatr Notifier service.

License

Notifications You must be signed in to change notification settings

Alwatr/notifier

Alwatr Notifier

npm version GitHub issues GitHub stars GitHub license

A tiny and easy-to-use package for sending notifications to Alwatr Notifier service.

Installation

npm install @alwatr/notifier

Usage

import {AlwatrNotifier} from '@alwatr/notifier';

const notifier = new AlwatrNotifier({
  categoryId: 'YOUR_CATEGORY_ID',
  accessToken: 'YOUR_ACCESS_TOKEN',
});

notifier.notify('Hello world!');

API

AlwatrNotifier(config)

Creates a new AlwatrNotifier instance.

Parameters:

  • config: AlwatrNotifierConfig - The configuration for the notifier.

    • apiUrl: string - The API URL for the notifier service. (default: 'https//notifier.alwatr.ir')
    • accessToken: string - The access token for the notifier service.
    • categoryId: string - The category ID for the notification. (default: 'demo')
    • markdown: boolean - Whether to send the message in markdown format. (default: false)
    • fetchOption: Partial<FetchOptions> - Fetch options for the API request. (default: {method: 'POST'})

Example:

const notifier = new AlwatrNotifier({
  categoryId: 'YOUR_CATEGORY_ID',
  accessToken: 'YOUR_ACCESS_TOKEN',
});

notify(message, option?)

Sends a notification to the Alwatr Notifier service.

Parameters:

  • message: string - The message to send.

  • option: NotifyOption - Optional parameters for the notification.

    • categoryId: string - The category ID for the notification.
    • markdown: boolean - Whether to send the message in markdown format.
    • fetchOption: Partial<FetchOptions> - Fetch options for the API request.

Returns:

  • Promise<ResponseError | ResponseSuccess<JsonObject>> - A promise that resolves with the API response.

Example:

notifier.notify('Hello world!');

Example with options:

notifier.notify('## Hello world\!', {
  categoryId: 'my-category',
  markdown: true,
});

Sponsors

The following companies, organizations, and individuals support this project ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Exir Studio

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.

License

This project is licensed under the AGPL-3.0 License.

About

A tiny and easy-to-use package for sending notifications to Alwatr Notifier service.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages