Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
slack-notify
Advanced tools
Readme
A simple, flexible, zero-dependency Node.js wrapper around the Slack webhook API. Makes it easy to send notifications to Slack from your application.
npm install slack-notify
// Import module:
import SlackNotify from 'slack-notify';
const MY_SLACK_WEBHOOK_URL = 'https://hooks.slack.com/services/RANDOMCHARS';
const slack = SlackNotify(MY_SLACK_WEBHOOK_URL);
// Example sending just text, using the Slack-provided configuration:
slack.send('Hello!')
.then(() => {
console.log('done!');
}).catch((err) => {
console.error(err);
});
// The Slack-provided configuration can be overridden:
slack.send({
channel: '#myCustomChannelName',
icon_url: 'http://example.com/my-icon.png',
text: 'Here is my notification',
unfurl_links: 1,
username: 'Jimmy'
});
// Roll your own notification type:
var statLog = slack.extend({
channel: '#statistics',
icon_emoji: ':computer:',
username: 'Statistics'
});
statLog({
text: 'Current server statistics',
fields: {
'CPU usage': '7.51%',
'Memory usage': '254mb'
}
});
// Promises are supported:
slack.send('Hello!').then(() => {
console.log('Done!');
}).catch((err) => {
console.error('API error:', err);
})
// Three pre-configured methods are provided:
// Posts to #bugs by default:
slack.bug('Something broke!');
// Posts to #alerts by default:
slack.success('Something happened correctly!');
slack.alert('Something important!');
// Send custom fields which are nicely displayed by the Slack client:
slack.alert({
text: 'Current server stats',
fields: {
'CPU usage': '7.51%',
'Memory usage': '254mb'
}
});
// The `fields` object is custom shorthand for the `attachments` array, which is also supported.
slack.alert({
text: 'Current server stats',
attachments: [
{
fallback: 'Required Fallback String',
fields: [
{ title: 'CPU usage', value: '7.51%', short: true },
{ title: 'Memory usage', value: '254mb', short: true }
]
}
]
});
// Set slack message color
slack.alert({
text: 'Current server stats',
attachments: [
{
fallback: 'Required Fallback String',
color: '#FF0000',
fields: [
{ title: 'CPU usage', value: '90%', short: true },
{ title: 'Memory usage', value: '254mb', short: true }
]
}
]
});
npm install
npm test
This library supports CommonJS and ES Modules.
// Require as Common JS:
const SlackNotify = require('slack-notify');
// Import as ES Module:
import SlackNotify from 'slack-notify';
// Either:
const slack = SlackNotify(MY_SLACK_WEBHOOK_URL);
MIT. Copyright © 2014-2023 Andrew Childs
FAQs
A simple Node.js wrapper around the Slack webhook API.
The npm package slack-notify receives a total of 72,107 weekly downloads. As such, slack-notify popularity was classified as popular.
We found that slack-notify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.