0.59.11 โ€ข Published 2 months ago

@stacksjs/notifications v0.59.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Stacks Notifications

Stacks Notifications is a unified driver system for sending messages/notifications. It supports sending emails, SMS messages, and chat messages.

โ˜˜๏ธ Features

  • ๐Ÿ“ฆ Send Emails
  • ๐ŸŽจ Email Styling
  • ๐Ÿ“ฑ Send SMS messages
  • ๐Ÿ’ฌ Send Chat messages

TODO

  • Driver: SNS (Push)
  • Driver: Pushwoosh

๐Ÿค– Usage

bun install -d @stacksjs/notifications

Set these variables in your env:

NOTIFICATION_TYPE=email
NOTIFICATION_DRIVER=sendgrid

You may now use it in your project:

import { notification } from '@stacksjs/notifications'

notification.send(options)

๐ŸŽ๏ธ Drivers

There are different option types for Chat, Email, and SMS drivers. To use any driver, simply configure the notification options object.

interface ChatOptions {
  providerName?: 'discord' | 'slack'
  webhookUrl: string
  content: string
}

interface EmailOptions {
  providerName?: 'sendgrid' | 'emailjs' | 'mailjet' | 'mandrill' | 'netcore' | 'nodemailer' | 'postmark' | 'ses'
  to: string | string[]
  subject: string
  html: string
  from?: string
  text?: string
  attachments?: AttachmentOptions[]
  id?: string
}

interface SMSOptions {
  providerName?: 'gupshup' | 'nexmo' | 'plivo' | 'sms77' | 'sns' | 'telnyx' | 'termii' | 'twilio'
  to: string
  content: string
  from?: string
  attachments?: AttachmentOptions[]
  id?: string
}

Available drivers are listed below, with the proper variables needed to get started.

Email

Email drivers are configured with the following environment variables:

Sendgrid

SENDGRID_API_KEY=SG123
SENDGRID_FROM=from@example.com
SENDGRID_SENDER_NAME=Sender

Mailgun

MAILGUN_API_KEY=MG123
MAILGUN_DOMAIN=example.com
MAILGUN_USERNAME=username
MAILGUN_FROM=from@example.com

Mailjet

MAILJET_API_KEY=MJ123
MAILJET_API_SECRET=MJTESTSECRET
MAILJET_FROM_EMAIL=from@example.com

Netcore

NETCORE_API_KEY=NC123
NETCORE_FROM=from@example.com

Nodemailer

NODEMAILER_FROM_EMAIL=from@example.com
NODEMAILER_HOST=example.com
NODEMAILER_USERNAME=username
NODEMAILER_PASSWORD=password
NODEMAILER_PORT=25
NODEMAILER_SECURE=true

Postmark

POSTMARK_API_KEY=PM123
POSTMARK_FROM=from@example.com

AWS SES

SES_REGION=US
SES_ACCESS_KEY_ID=testkey123
SES_SECRET_ACCESS_KEY=testaccesskey123
SES_FROM=from@example.com

Mandrill

MANDRILL_API_KEY=Ma123
MANDRILL_EMAIL=from@example.com

EmailJS

MAIL_FROM_ADDRESS=from@example.com
EMAILJS_HOST=example.com
EMAILJS_USERNAME=username
EMAILJS_PASSWORD=password
EMAILJS_PORT=25
EMAILJS_SECURE=true

SMS

SMS drivers are configured with the following environment variables:

Twilio

TWILIO_ACCOUNT_SID=ACtest
TWILIO_AUTH_TOKEN=testtoken
TWILIO_FROM_NUMBER=+112345
TWILIO_TO_NUMBER=+145678

Nexmo

VONAGE_API_KEY=VN123
VONAGE_API_SECRET=testkey
VONAGE_FROM_NUMBER=+112345

Gupshup

GUPSHUP_USER_ID=GU123
GUPSHUP_PASSWORD=password

Plivo

PLIVO_ACCOUNT_ID=PA123
PLIVO_AUTH_TOKEN=testtoken
PLIVO_FROM_NUMBER=+112345

SMS77

SMS77_API_KEY=SA123
SMS77_FROM=from@example.com

SNS

SMS77_API_KEY=SA123
SMS77_FROM=from@example.com

Telnyx

TELNYX_API_KEY=TA123
TELNYX_MESSAGE_PROFILE_ID=testprofileid
TELNYX_FROM=from@example.com

Termii

TERMII_API_KEY=TermA123
TERMII_SENDER=from@example.com

Chat

Chat drivers are configured with the following environment variables:

Discord

  • None

Slack

SLACK_APPLICATION_ID=SAID123
SLACK_CLIENT_ID=SCID123
SLACK_SECRET_KEY=SSK123

Learn more in the docs.

๐Ÿงช Testing

bun test

๐Ÿ“ˆ Changelog

Please see our releases page for more information on what has changed recently.

๐Ÿšœ Contributing

Please review the Contributing Guide for details.

๐Ÿ Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the Stacks Discord Server

๐Ÿ™๐Ÿผ Credits

Many thanks to the following core technologies & people who have contributed to this package:

๐Ÿ“„ License

The MIT License (MIT). Please see LICENSE for more information.

Made with ๐Ÿ’™

0.59.11

2 months ago

0.59.8

2 months ago

0.59.9

2 months ago

0.59.7

2 months ago

0.59.10

2 months ago

0.59.2

2 months ago

0.59.3

2 months ago

0.59.1

2 months ago

0.59.6

2 months ago

0.59.4

2 months ago

0.59.5

2 months ago

0.58.73

2 months ago

0.58.72

2 months ago

0.58.70

2 months ago

0.58.71

2 months ago

0.58.69

2 months ago

0.58.65

2 months ago

0.58.66

2 months ago

0.58.67

2 months ago

0.58.68

2 months ago

0.58.60

3 months ago

0.58.61

3 months ago

0.58.62

3 months ago

0.58.63

2 months ago

0.58.64

2 months ago

0.58.59

3 months ago

0.58.58

3 months ago

0.58.57

3 months ago

0.58.56

3 months ago

0.58.55

3 months ago

0.58.52

3 months ago

0.58.53

3 months ago

0.58.50

3 months ago

0.58.51

3 months ago

0.58.49

3 months ago

0.58.47

3 months ago

0.58.48

3 months ago

0.58.43

3 months ago

0.58.44

3 months ago

0.58.45

3 months ago

0.58.46

3 months ago

0.58.27

3 months ago

0.58.28

3 months ago

0.58.19

4 months ago

0.58.20

4 months ago

0.58.21

4 months ago

0.58.22

4 months ago

0.58.24

4 months ago

0.57.4

10 months ago

0.57.2

10 months ago

0.57.3

10 months ago

0.56.24

10 months ago

0.56.23

10 months ago

0.56.28

10 months ago

0.56.27

10 months ago

0.56.29

10 months ago

0.56.35

10 months ago

0.56.34

10 months ago

0.56.31

10 months ago

0.56.30

10 months ago

0.56.33

10 months ago

0.56.32

10 months ago

0.56.3

10 months ago

0.52.10

11 months ago

0.53.1

11 months ago

0.52.9

11 months ago

0.52.7

11 months ago

0.52.8

11 months ago

0.52.5

11 months ago

0.52.6

11 months ago

0.52.3

11 months ago

0.52.4

11 months ago

0.52.1

11 months ago

0.52.2

11 months ago

0.52.0

12 months ago

0.51.0

1 year ago

0.50.0

1 year ago

0.44.10

1 year ago

0.49.1

1 year ago

0.48.2

1 year ago

0.46.4

1 year ago

0.44.11

1 year ago

0.44.6

1 year ago

0.49.2

1 year ago

0.48.3

1 year ago

0.47.4

1 year ago

0.44.12

1 year ago

0.44.7

1 year ago

0.46.2

1 year ago

0.49.0

1 year ago

0.48.1

1 year ago

0.46.3

1 year ago

0.46.0

1 year ago

0.45.1

1 year ago

0.46.1

1 year ago

0.45.2

1 year ago

0.45.0

1 year ago

0.49.3

1 year ago

0.44.8

1 year ago

0.44.9

1 year ago

0.43.1

1 year ago

0.43.0

1 year ago

0.42.2

1 year ago

0.42.1

1 year ago

0.41.1

1 year ago

0.41.0

1 year ago

0.40.0

1 year ago

0.39.1

1 year ago

0.39.0

1 year ago

0.38.4

1 year ago

0.38.3

1 year ago