0.6.0 • Published 4 years ago

fire-slack v0.6.0

Weekly downloads
392
License
MIT
Repository
github
Last release
4 years ago

fire-slack npm version Build Status Codacy Badge License: MIT

fire-slack is a library that makes it easy and convenient to send Slack's Incoming Webhook from Cloud Functions.

Feature

  • Automatically add project_id.
  • Add a link url to firebase's database. (optional)
  • Add a error message and change it to red color. (optional)

Like this gif, firebase's database can be opened.

Installation

npm install --save fire-slack

Usage

1. Initialize

Initialize fire-slack in your index.ts.

import * as Slack from 'fire-slack'

Slack.initialize(
    <admin.AppOptions>functions.config().firebase,
    'https://your-incoming-webhook-url',
    { channel: 'default_channel', iconEmoji: ':default:', username: 'default_usern' } // optional
)

2. Send to slack

For example, when an error occurs on Cloud Functions.

webhook options are the same as options in Incoming webhook. See Incoming Webhooks | Slack or typed-slack.d.ts.

export const orderPaymentRequested = functions.firestore
    .document(`sampleorder/{orderID}`).onCreate(async event => {

  try {
    return event.data.ref.update({ name: 'new name' })
  } catch (error) {
    // ref and error are optional.
    await Slack.send({ webhook: { text: 'An error occurred!' }, ref: event.data.ref, error: error })
    return Promise.reject(error)
  }
})

result:

0.6.0

4 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago