A tiny and easy-to-use package for sending notifications to Alwatr Notifier service.
npm install @alwatr/notifier
import {AlwatrNotifier} from '@alwatr/notifier';
const notifier = new AlwatrNotifier({
categoryId: 'YOUR_CATEGORY_ID',
accessToken: 'YOUR_ACCESS_TOKEN',
});
notifier.notify('Hello world!');
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',
});
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,
});
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.
Contributions are welcome! Please read our contribution guidelines before submitting a pull request.
This project is licensed under the AGPL-3.0 License.