mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Latest Code
This commit is contained in:
1
node_modules/pushover-notifications/.npmignore
generated
vendored
Normal file
1
node_modules/pushover-notifications/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
npm-debug.log
|
16
node_modules/pushover-notifications/LICENSE
generated
vendored
Normal file
16
node_modules/pushover-notifications/LICENSE
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Aaron Bieber <deftly@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
89
node_modules/pushover-notifications/README.md
generated
vendored
Normal file
89
node_modules/pushover-notifications/README.md
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||

|
||||
|
||||
Send [pushover.net](http://pushover.net) notifications from Node.JS
|
||||
|
||||
## Usage
|
||||
|
||||
### Install
|
||||
|
||||
npm install pushover-notifications
|
||||
|
||||
### Pushover API values
|
||||
|
||||
Any API paramaters, as found on https://pushover.net/api, can be passed in the object. For example, `retry` and `expire` can be added to the object being passed to `.send`! Here's an example with many different parameters.
|
||||
```javascript
|
||||
var msg = {
|
||||
message: "This is a message",
|
||||
title: "Well - this is fantastic",
|
||||
sound: 'magic',
|
||||
device: 'test_device',
|
||||
priority: 2,
|
||||
url: "http://pushover.net",
|
||||
url_title: "Pushover Website"
|
||||
};
|
||||
```
|
||||
## Examples
|
||||
|
||||
### Sending a message
|
||||
```javascript
|
||||
|
||||
var push = require( 'pushover-notifications' );
|
||||
|
||||
var p = new push( {
|
||||
user: process.env['PUSHOVER_USER'],
|
||||
token: process.env['PUSHOVER_TOKEN'],
|
||||
// onerror: function(error) {},
|
||||
// update_sounds: true // update the list of sounds every day - will
|
||||
// prevent app from exiting.
|
||||
});
|
||||
|
||||
var msg = {
|
||||
// These values correspond to the parameters detailed on https://pushover.net/api
|
||||
// 'message' is required. All other values are optional.
|
||||
message: 'omg node test', // required
|
||||
title: "Well - this is fantastic",
|
||||
sound: 'magic',
|
||||
device: 'devicename',
|
||||
priority: 1
|
||||
};
|
||||
|
||||
p.send( msg, function( err, result ) {
|
||||
if ( err ) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log( result );
|
||||
});
|
||||
```
|
||||
|
||||
### Sending a message to multiple users
|
||||
```javascript
|
||||
|
||||
var users = [
|
||||
'token1',
|
||||
'token2',
|
||||
'token3'
|
||||
];
|
||||
|
||||
var msg = {
|
||||
message: 'omg node test',
|
||||
title: "Well - this is fantastic",
|
||||
sound: 'magic' // optional
|
||||
priority: 1 // optional,
|
||||
};
|
||||
|
||||
for ( var i = 0, l = users.length; i < l; i++ ) {
|
||||
|
||||
msg.user = users[i];
|
||||
// token can be overwritten as well.
|
||||
|
||||
p.send( msg, function( err, result ) {
|
||||
if ( err ) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log( result );
|
||||
});
|
||||
}
|
||||
|
||||
```
|
1
node_modules/pushover-notifications/index.js
generated
vendored
Normal file
1
node_modules/pushover-notifications/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require( './lib/pushover' );
|
180
node_modules/pushover-notifications/lib/pushover.js
generated
vendored
Normal file
180
node_modules/pushover-notifications/lib/pushover.js
generated
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
var https = require('https'),
|
||||
url = require('url'),
|
||||
qs = require('querystring'),
|
||||
p_url = 'https://api.pushover.net/1/messages.json';
|
||||
|
||||
function setDefaults(o) {
|
||||
var def = [
|
||||
'device',
|
||||
'title',
|
||||
'url',
|
||||
'url_title',
|
||||
'priority',
|
||||
'timestamp',
|
||||
'sound'
|
||||
];
|
||||
|
||||
var i = 0; l = def.length;
|
||||
for (; i < l; i++) {
|
||||
if (!o[def[i]]) {
|
||||
o[def[i]] = '';
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
function Pushover(opts) {
|
||||
var self = this;
|
||||
this.token = opts.token;
|
||||
this.user = opts.user;
|
||||
this.httpOptions = opts.httpOptions;
|
||||
this.sounds = {
|
||||
"pushover":"Pushover (default)",
|
||||
"bike":"Bike",
|
||||
"bugle":"Bugle",
|
||||
"cashregister":"Cash Register",
|
||||
"classical":"Classical",
|
||||
"cosmic":"Cosmic",
|
||||
"falling":"Falling",
|
||||
"gamelan":"Gamelan",
|
||||
"incoming":"Incoming",
|
||||
"intermission":"Intermission",
|
||||
"magic":"Magic",
|
||||
"mechanical":"Mechanical",
|
||||
"pianobar":"Piano Bar",
|
||||
"siren":"Siren",
|
||||
"spacealarm":"Space Alarm",
|
||||
"tugboat":"Tug Boat",
|
||||
"alien":"Alien Alarm (long)",
|
||||
"climb":"Climb (long)",
|
||||
"persistent":"Persistent (long)",
|
||||
"echo":"Pushover Echo (long)",
|
||||
"updown":"Up Down (long)",
|
||||
"none":"None (silent)"
|
||||
};
|
||||
|
||||
if (opts.debug) {
|
||||
this.debug = opts.debug;
|
||||
}
|
||||
|
||||
if (opts.onerror) {
|
||||
this.onerror = opts.onerror;
|
||||
}
|
||||
|
||||
if (opts.update_sounds) {
|
||||
self.updateSounds();
|
||||
setInterval(function() {
|
||||
self.updateSounds();
|
||||
}, 86400000);
|
||||
}
|
||||
}
|
||||
|
||||
Pushover.prototype.errors = function(d) {
|
||||
if (typeof d === 'string') {
|
||||
d = JSON.parse(d);
|
||||
}
|
||||
|
||||
if (d.errors) {
|
||||
if (this.onerror) {
|
||||
this.onerror.call(null, d.errors[0]);
|
||||
} else {
|
||||
throw new Error(d.errors[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Pushover.prototype.updateSounds = function() {
|
||||
var self = this, data = '';
|
||||
var surl = 'https://api.pushover.net/1/sounds.json?token=' + self.token;
|
||||
var req = https.request(url.parse(surl) , function(res) {
|
||||
res.on('end', function() {
|
||||
var j = JSON.parse(data);
|
||||
self.errors(data);
|
||||
self.sounds = j.sounds;
|
||||
});
|
||||
|
||||
res.on('data', function(chunk) {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
req.on('error', function(e) {
|
||||
err = e;
|
||||
});
|
||||
|
||||
req.write('');
|
||||
req.end();
|
||||
};
|
||||
|
||||
Pushover.prototype.send = function(obj, fn) {
|
||||
var self = this;
|
||||
var o = url.parse(p_url);
|
||||
o.method = "POST";
|
||||
|
||||
obj = setDefaults(obj);
|
||||
|
||||
if (! self.sounds[ obj.sound ]) {
|
||||
obj.sound = 'pushover';
|
||||
}
|
||||
|
||||
var req_string = {
|
||||
token: self.token || obj.token,
|
||||
user: self.user || obj.user
|
||||
};
|
||||
|
||||
var p;
|
||||
for (p in obj) {
|
||||
req_string[ p ] = obj[p];
|
||||
}
|
||||
|
||||
req_string = qs.stringify(req_string);
|
||||
|
||||
o.headers = {
|
||||
'Content-Length': req_string.length
|
||||
};
|
||||
|
||||
var httpOpts = self.httpOptions;
|
||||
if (httpOpts) {
|
||||
Object.keys(httpOpts).forEach(function(key) {
|
||||
o[key] = httpOpts[key];
|
||||
});
|
||||
}
|
||||
|
||||
var req = https.request(o, function(res) {
|
||||
if (self.debug) {
|
||||
console.log(res.statusCode);
|
||||
}
|
||||
var err;
|
||||
var data = '';
|
||||
res.on('end', function() {
|
||||
self.errors(data);
|
||||
if (fn) {
|
||||
fn.call(null, err, data);
|
||||
}
|
||||
});
|
||||
|
||||
res.on('data', function(chunk) {
|
||||
data += chunk;
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', function(err) {
|
||||
if (fn) {
|
||||
fn.call(null, err);
|
||||
}
|
||||
// In the tests the "end" event did not get emitted if "error" was emitted,
|
||||
// but to be sure that the callback is not get called twice, null the callback function
|
||||
fn = null;
|
||||
});
|
||||
|
||||
|
||||
if (self.debug) {
|
||||
console.log (req_string);
|
||||
}
|
||||
req.write(req_string);
|
||||
req.end();
|
||||
};
|
||||
|
||||
exports = module.exports = Pushover;
|
28
node_modules/pushover-notifications/package.json
generated
vendored
Normal file
28
node_modules/pushover-notifications/package.json
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Aaron Bieber",
|
||||
"email": "aaron@qbit.io"
|
||||
},
|
||||
"name": "pushover-notifications",
|
||||
"description": "Pushover API for node.js",
|
||||
"version": "0.2.2",
|
||||
"homepage": "http://github.com/qbit/node-pushover",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/qbit/node-pushover.git"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"readme": "\n\nSend [pushover.net](http://pushover.net) notifications from Node.JS\n\n## Usage\n\n### Install\n\n\tnpm install pushover-notifications\n\t\n### Pushover API values\n\nAny API paramaters, as found on https://pushover.net/api, can be passed in the object. For example, `retry` and `expire` can be added to the object being passed to `.send`! Here's an example with many different parameters.\n```javascript\nvar msg = {\n\tmessage: \"This is a message\",\n\ttitle: \"Well - this is fantastic\",\n\tsound: 'magic',\n\tdevice: 'test_device',\n\tpriority: 2,\n\turl: \"http://pushover.net\",\n\turl_title: \"Pushover Website\"\n};\n```\n## Examples\n\n### Sending a message\n```javascript\n\nvar push = require( 'pushover-notifications' );\n\nvar p = new push( {\n\tuser: process.env['PUSHOVER_USER'],\n\ttoken: process.env['PUSHOVER_TOKEN'],\n\t// onerror: function(error) {},\n\t// update_sounds: true // update the list of sounds every day - will\n\t// prevent app from exiting.\n});\n\nvar msg = {\n\t// These values correspond to the parameters detailed on https://pushover.net/api\n\t// 'message' is required. All other values are optional.\n\tmessage: 'omg node test',\t// required\n\ttitle: \"Well - this is fantastic\",\n\tsound: 'magic',\n\tdevice: 'devicename',\n\tpriority: 1\n};\n\np.send( msg, function( err, result ) {\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\n\tconsole.log( result );\n});\n```\n\n### Sending a message to multiple users\n```javascript\n\nvar users = [\n 'token1',\n 'token2',\n 'token3'\n];\n\nvar msg = {\n message: 'omg node test',\n title: \"Well - this is fantastic\",\n sound: 'magic' // optional\n priority: 1 // optional,\n};\n\nfor ( var i = 0, l = users.length; i < l; i++ ) {\n\n msg.user = users[i];\n // token can be overwritten as well.\n\n p.send( msg, function( err, result ) {\n if ( err ) {\n throw err;\n }\n\n console.log( result );\n });\n}\n\n```\n",
|
||||
"readmeFilename": "README.md",
|
||||
"_id": "pushover-notifications@0.2.2",
|
||||
"dist": {
|
||||
"shasum": "b151e5729b7014d84dcb71b1a86c247c124eb277"
|
||||
},
|
||||
"_from": "pushover-notifications@",
|
||||
"_resolved": "https://registry.npmjs.org/pushover-notifications/-/pushover-notifications-0.2.2.tgz"
|
||||
}
|
25
node_modules/pushover-notifications/test/test-onerror.js
generated
vendored
Normal file
25
node_modules/pushover-notifications/test/test-onerror.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
var push = require( '../lib/pushover.js' );
|
||||
|
||||
var p = new push( {
|
||||
user: process.env['PUSHOVER_USER'],
|
||||
token: process.env['PUSHOVER_TOKEN'],
|
||||
update_sounds: false,
|
||||
debug: true,
|
||||
onerror: function(err) {
|
||||
console.log('ERROR!', err);
|
||||
}
|
||||
});
|
||||
|
||||
var msg = {
|
||||
message: 'omg node test',
|
||||
sound: 'magic',
|
||||
title: "Well - this is fantastic",
|
||||
};
|
||||
|
||||
// console.log( p );
|
||||
|
||||
p.send( msg, function( err, result ) {
|
||||
console.log( 'error', err );
|
||||
console.log( 'result', result );
|
||||
// process.exit(0);
|
||||
});
|
22
node_modules/pushover-notifications/test/test.js
generated
vendored
Normal file
22
node_modules/pushover-notifications/test/test.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
var push = require( '../lib/pushover.js' );
|
||||
|
||||
var p = new push( {
|
||||
user: process.env['PUSHOVER_USER'],
|
||||
token: process.env['PUSHOVER_TOKEN'],
|
||||
update_sounds: false,
|
||||
debug: true
|
||||
});
|
||||
|
||||
var msg = {
|
||||
message: 'omg node test',
|
||||
sound: 'magic',
|
||||
title: "Well - this is fantastic",
|
||||
};
|
||||
|
||||
// console.log( p );
|
||||
|
||||
p.send( msg, function( err, result ) {
|
||||
console.log( 'error', err );
|
||||
console.log( 'result', result );
|
||||
// process.exit(0);
|
||||
});
|
21
node_modules/pushover-notifications/test/test_multi.js
generated
vendored
Normal file
21
node_modules/pushover-notifications/test/test_multi.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
var push = require( '../lib/pushover.js' );
|
||||
|
||||
var p = new push( {
|
||||
// user: process.env['PUSHOVER_USER'],
|
||||
token: process.env['PUSHOVER_TOKEN'],
|
||||
debug: true
|
||||
});
|
||||
|
||||
var msg = {
|
||||
message: 'omg node test',
|
||||
title: "Well - this is fantastic",
|
||||
user: process.env['PUSHOVER_USER']
|
||||
};
|
||||
|
||||
// console.log( p );
|
||||
|
||||
p.send( msg, function( err, result ) {
|
||||
console.log( err );
|
||||
console.log( result );
|
||||
process.exit(0);
|
||||
});
|
Reference in New Issue
Block a user