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

pino-http-send

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

pino-http-send - npm Package Compare versions

Comparing version 0.4.0 to 0.4.2

dist/bin.d.ts

10

dist/index.d.ts

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

#!/usr/bin/env node
export declare function safeParse(src: string): any;
import Pumpify from 'pumpify';
import { Args } from './args';
/**
* Creates a writable stream that handles logs, batches them, and then sends
* them to the configured endpoint.
* @param options
*/
export declare function createWriteStream(args: Args): Pumpify;

45

dist/index.js

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

#!/usr/bin/env node
"use strict";

@@ -7,4 +6,4 @@ var __importDefault = (this && this.__importDefault) || function (mod) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.safeParse = void 0;
const pump_1 = __importDefault(require("pump"));
exports.createWriteStream = void 0;
const pumpify_1 = __importDefault(require("pumpify"));
const split2_1 = __importDefault(require("split2"));

@@ -14,22 +13,38 @@ const through2_1 = __importDefault(require("through2"));

const handle_1 = require("./handle");
args_1.loadArgs();
/**
* Safely parses incoming JSON and logs the source if an error is thrown.
* @param src
*/
function safeParse(src) {
try {
const parsed = JSON.parse(src);
if (args_1.args.log) {
console.log(src);
}
return parsed;
}
catch (e) {
if (args_1.args.log) {
console.log(src);
}
console.log(src);
}
}
exports.safeParse = safeParse;
const transport = through2_1.default.obj((log, _enc, callback) => {
handle_1.handleLog(log, callback);
});
pump_1.default(process.stdin, split2_1.default(safeParse), transport);
/**
* Passes the incoming stream through the proper callback.
* @param args
*/
function streamHandler() {
return through2_1.default.obj((log, _enc, callback) => {
handle_1.handleLog(log, callback);
});
}
/**
* Creates a writable stream that handles logs, batches them, and then sends
* them to the configured endpoint.
* @param options
*/
function createWriteStream(args) {
// make sure url is defined right away
if (!args.url || !args.url.trim()) {
throw new Error('args.url is required');
}
args_1.setArgs(args);
return new pumpify_1.default(split2_1.default(safeParse), streamHandler());
}
exports.createWriteStream = createWriteStream;
//# sourceMappingURL=index.js.map
{
"name": "pino-http-send",
"version": "0.4.0",
"version": "0.4.2",
"description": "",

@@ -27,3 +27,3 @@ "keywords": [

"bin": {
"pino-http-send": "./dist/index.js"
"pino-http-send": "./dist/bin.js"
},

@@ -30,0 +30,0 @@ "files": [

@@ -94,6 +94,2 @@ # pino-http-send

**It's important that you don't import/require from index when using as an API
stream. Doing so willl require CLI args to be defined as this is a CLI-first
package.**
### `createWriteStream`

@@ -120,3 +116,3 @@

```ts
import { createWriteStream } from 'pino-http-send/dist/stream';
import { createWriteStream } from 'pino-http-send';

@@ -123,0 +119,0 @@ const stream = createWriteStream({

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