Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winston-hipchat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-hipchat - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

60

lib/winston-hipchat.js
'use strict';
var util = require('util'),
winston = require('winston'),
request = require('request'),
Stream = require('stream').Stream
var util = require('util')
, winston = require('winston')
, request = require('request')
, Stream = require('stream').Stream
, _ = require('lodash')

@@ -17,18 +18,12 @@ //

options = options || {}
if (!options.room) throw new Error('Must have a room option set.')
if (!options.token) throw new Error('Must have a token option set.')
this.name = 'http'
this.ssl = true
this.host = 'api.hipchat.com'
this.port = 443
this.silent = options.silent
this.token = options.token
this.room = options.room
this.from = options.from || 'winston'
this.notify = options.notify ? 1 : 0
this.color = options.color || 'yellow'
this.path = '/v1/rooms/message'
this.name = 'Hipchat'
this.options = _.defaults(options || {}, {
from: 'winston'
, notify: 0
, color: 'yellow'
, messageFormat: 'text'
})
}

@@ -41,3 +36,3 @@

//
Hipchat.prototype.name = 'http'
Hipchat.prototype.name = 'Hipchat'

@@ -51,25 +46,18 @@ //

Hipchat.prototype._request = function (options, callback) {
var auth
options = options || {}
options.method = 'POST'
options.params.meta = Object.keys(options.params.meta).length ? JSON.stringify(options.params.meta, null, 2) : ''
options.qs = {
'room_id': this.room
, from: this.from
, 'auth_token': this.token
, notify: this.notify
, color: this.color
, 'message_format': 'text'
, message: options.params.message + (Object.keys(options.params.meta).length? '\n\n' + JSON.stringify(options.params.meta) : '')
'room_id': this.options.room
, from: this.options.from
, 'auth_token': this.options.token
, notify: this.options.notify ? 1 : 0
, color: this.options.color
, 'message_format': this.options.messageFormat
, message: this.options.message ? _.template(this.options.message, options.params, {
interpolate: /\{\{(.*?)\}\}/g
}) : options.params.message + (options.params.meta ? '\n\n' + options.params.meta : '')
}
options.url = 'http'
+ (this.ssl ? 's' : '')
+ '://'
+ (auth ? auth.username + ':' : '')
+ (auth ? auth.password + '@' : '')
+ this.host
+ ':'
+ this.port
+ this.path
options.url = 'https://api.hipchat.com/v1/rooms/message'

@@ -76,0 +64,0 @@ return request(options, callback)

{
"name": "winston-hipchat",
"version": "0.0.2",
"version": "0.1.0",
"description": "A Hipchat transport for winston",

@@ -20,3 +20,4 @@ "author": "Joey Baker <joey@byjoeybaker.com>",

"dependencies": {
"request": "~2.27.0"
"request": "~2.27.0",
"lodash": "~2.2.1"
},

@@ -23,0 +24,0 @@ "devDependencies": {

2

README.md

@@ -24,2 +24,4 @@ # winston-hipchat

* __from:__ Required. Name the message will appear be sent from. Must be less than 15 characters long. May contain letters, numbers, -, _, and spaces.
* __messageFormat:__ `text` (default) or `html`.
* __message:__ [lodash templates](http://lodash.com/docs#template). Gets passed the `{{message}}`, `{{level}}`, and `{{meta}}` as a JSON string. If not specified, it will print a default of `{{message}}\n\n{{meta}}`

@@ -26,0 +28,0 @@ ## Installation

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