Socket
Socket
Sign inDemoInstall

slack-node

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slack-node - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

example/api.postMessage.js

2

lib/index.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.9.0
// Generated by CoffeeScript 1.7.1
module.exports = require("./lib/slack.seed");

@@ -1,11 +0,15 @@

// Generated by CoffeeScript 1.9.0
var Slack, request,
// Generated by CoffeeScript 1.7.1
var DEFAULT_MAX_ATTEMPTS, DEFAULT_TIMEOUT, Slack, request,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
request = require("request");
request = require("requestretry");
DEFAULT_TIMEOUT = 10 * 1000;
DEFAULT_MAX_ATTEMPTS = 3;
Slack = (function() {
function Slack(_at_token, _at_domain) {
this.token = _at_token;
this.domain = _at_domain;
function Slack(token, domain) {
this.token = token;
this.domain = domain;
this.api = __bind(this.api, this);

@@ -18,2 +22,4 @@ this.webhook = __bind(this.webhook, this);

this.url = this.composeUrl();
this.timeout = DEFAULT_TIMEOUT;
this.maxAttempts = DEFAULT_MAX_ATTEMPTS;
}

@@ -53,7 +59,14 @@

payload[emoji.key] = emoji.val;
return request.post({
return request({
method: "POST",
url: this.webhookUrl,
body: JSON.stringify(payload)
body: JSON.stringify(payload),
timeout: this.timeout,
maxAttempts: this.maxAttempts,
retryDelay: 0
}, function(err, body, response) {
return callback(err, {
if (err != null) {
return callback(err);
}
return callback(null, {
status: err || response !== "ok" ? "fail" : "ok",

@@ -79,3 +92,6 @@ statusCode: body.statusCode,

request_arg = {
url: this.url + method
url: this.url + method,
timeout: this.timeout,
maxAttempts: this.maxAttempts,
retryDelay: 0
};

@@ -82,0 +98,0 @@ if (this._is_post_api(method)) {

@@ -1,8 +0,14 @@

// Generated by CoffeeScript 1.9.0
var Slack, apiToken, domain, should, webhookToken, webhookUri;
// Generated by CoffeeScript 1.7.1
var Slack, apiToken, domain, nock, should, url, webhookToken, webhookUri;
should = require("should");
nock = require("nock");
url = require("url");
Slack = require("../index");
nock.enableNetConnect();
domain = "slack-node";

@@ -31,2 +37,5 @@

}, function(err, response) {
if (err) {
return done(err);
}
response.should.be.ok.and.an.Object;

@@ -43,2 +52,5 @@ return done();

}, function(err, response) {
if (err) {
return done(err);
}
response.should.be.ok.and.an.Object;

@@ -55,2 +67,5 @@ return done();

}, function(err, response) {
if (err) {
return done(err);
}
response.statusCode.should.be.a.Number;

@@ -121,1 +136,27 @@ response.headers.should.be.an.Object;

});
describe("retry test", function() {
var slack;
this.timeout(50000);
slack = null;
beforeEach(function() {
slack = new Slack();
slack.setWebhook(webhookUri);
return slack.timeout = 10;
});
return it("Should retry if a request to slack fails after a timeout", function(done) {
var mockWebhook, webhookDetails;
webhookDetails = url.parse(webhookUri);
mockWebhook = nock(webhookDetails.protocol + "//" + webhookDetails.host).post(webhookDetails.path).times(3).socketDelay(20).reply(204, '');
return slack.webhook({
channel: "#general",
username: "webhookbot",
text: "This is posted to #general and comes from a bot named webhookbot."
}, function(err, response) {
should.exist(err);
should.not.exist(response);
should.equal(mockWebhook.isDone(), true);
return done();
});
});
});
{
"name": "slack-node",
"version": "0.1.0",
"version": "0.1.2",
"description": "slack for node verision, full support",

@@ -10,2 +10,6 @@ "main": "lib/index.js",

},
"repository": {
"type": "git",
"url": "https://github.com/clonn/slack-node-sdk.git"
},
"keywords": [

@@ -19,3 +23,3 @@ "slack",

"dependencies": {
"request": "~2.34.0"
"requestretry": "^1.2.2"
},

@@ -25,4 +29,5 @@ "devDependencies": {

"mocha": "^2.1.0",
"nock": "^1.2.0",
"should": "~3.3.1"
}
}

@@ -26,3 +26,3 @@ slack-node-sdk

slack = new Slack();
slack.setWebHook(webhookUri);
slack.setWebhook(webhookUri);

@@ -45,3 +45,3 @@ slack.webhook({

slack = new Slack();
slack.setWebHook(webhookUri);
slack.setWebhook(webhookUri);

@@ -52,3 +52,4 @@ // slack emoji

username: "webhookbot",
icon_emoji: ":ghost:"
icon_emoji: ":ghost:",
text: "test message, test message"
}, function(err, response) {

@@ -62,3 +63,4 @@ console.log(response);

username: "webhookbot",
icon_emoji: "http://icons.iconarchive.com/icons/rokey/popo-emotions/128/after-boom-icon.png"
icon_emoji: "http://icons.iconarchive.com/icons/rokey/popo-emotions/128/after-boom-icon.png",
text: "test message, test message"
}, function(err, response) {

@@ -68,2 +70,4 @@ console.log(response);

Otherwise, you can check usage from [example](https://github.com/clonn/slack-node-sdk/tree/master/example)
## Slack API support

@@ -88,9 +92,18 @@

slack.api('chat.postMessage', {text:'hello from nodejs', channel:'#general'}, function(){});
slack.api('chat.postMessage', {
text:'hello from nodejs',
channel:'#general'
}, function(err, response){
console.log(response);
});
## Changelog
* 0.0.96
* 0.1.2
* support ES6, promise function.
* 0.1.0
* fixed test type error
* support new [slack webhook](https://api.slack.com/incoming-webhooks).
* 0.0.95

@@ -97,0 +110,0 @@ * fixed webhook function and test

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc