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

winston-telegram

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-telegram - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

6

CHANGELOG.md

@@ -10,2 +10,5 @@ # Changelog

## [v1.4.2] - 2019-12-11
- [#16](https://github.com/ivanmarban/winston-telegram/issues/16) Use `Buffer.byteLength` to compute the `Content-Length` header.
## [v1.4.1] - 2019-06-22

@@ -64,3 +67,4 @@ - Code refactoring.

[unreleased]: https://github.com/ivanmarban/winston-telegram/compare/v1.4.1...1.x
[[unreleased]: https://github.com/ivanmarban/winston-telegram/compare/v1.4.2...1.x
[v1.4.2]: https://github.com/ivanmarban/winston-telegram/compare/v1.4.1...v1.4.2
[v1.4.1]: https://github.com/ivanmarban/winston-telegram/compare/v1.4.0...v1.4.1

@@ -67,0 +71,0 @@ [v1.4.0]: https://github.com/ivanmarban/winston-telegram/compare/v1.3.2...v1.4.0

2

examples/custom-format.js

@@ -18,3 +18,3 @@ /*

if (opts.level === 'warn') {
message = '[Warning] ' + message
message += '[Warning] '
}

@@ -21,0 +21,0 @@ return message

@@ -15,3 +15,3 @@ /*

* @constructs
* @param {object} options - Options.
* @param {Object} options - Options.
* @param {string} options.token - Telegram bot authentication token.

@@ -25,3 +25,3 @@ * @param {string} options.chatId - Telegram unique identifier for chat.

* @param {string} [options.name='winston-telegram'] - Logger's name.
* @param {object} [options.template='[{level}] {message}'] - Format output message based on named arguments.
* @param {Object} [options.template='[{level}] {message}'] - Format output message based on named arguments.
* @param {Function} [options.formatMessage] - Format output message by own method.

@@ -81,3 +81,3 @@ * @param {number} [options.batchingDelay=0] - Time in ms within which to batch messages together.

* @param {string} msg - Message to log.
* @param {object} [meta] - Additional metadata to attach.
* @param {Object} [meta] - Additional metadata to attach.
* @param {Function} callback - Continuation to respond to when complete.

@@ -116,3 +116,3 @@ * @returns {undefined}

callback(null, true)
return callback(null, true)
}

@@ -130,3 +130,3 @@

var requestData = JSON.stringify({
var messageData = JSON.stringify({
chat_id: this.chatId,

@@ -137,13 +137,3 @@ text: messageText,

var options = {
hostname: 'api.telegram.org',
path: '/bot' + this.token + '/sendMessage',
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Content-Length': requestData.length
}
}
self.request(options, requestData, function (error, response, body) {
self.request(messageData, function (error, response, body) {
if (error) {

@@ -164,22 +154,35 @@ self.emit('error', error)

/**
* Performs a https request to a server.
* Post message data to Telegram API.
*
* @function request
* @param {object} options - Request options.
* @param {object} requestData - Request data.
* @member Telegram
* @param {Object} messageData - Message data to post to Telegram API.
* @param {Function} callback - Continuation to respond to when complete.
* @returns {undefined}
*/
Telegram.prototype.request = function (options, requestData, callback) {
var request = https.request(options, function (response) {
var responseData = ''
response.on('data', function (chunk) {
responseData += chunk
})
response.on('end', function () {
callback(null, response, JSON.parse(responseData))
})
})
request.on('error', callback)
request.write(requestData, 'utf-8')
request.end()
Telegram.prototype.request = function (messageData, callback) {
var req = https.request(
{
hostname: 'api.telegram.org',
port: 443,
path: '/bot' + this.token + '/sendMessage',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(messageData)
}
},
function (response) {
var data = ''
response.on('data', function (chunk) {
data += chunk
})
response.on('end', function () {
callback(null, response, JSON.parse(data))
})
}
)
req.on('error', callback)
req.write(messageData)
req.end()
}
{
"name": "winston-telegram",
"description": "A Telegram transport for winston",
"version": "1.4.1",
"version": "1.4.2",
"author": "Ivan Marban",

@@ -6,0 +6,0 @@ "repository": {

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