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

elastic-apm-http-client

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-apm-http-client - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

8

index.js

@@ -15,7 +15,5 @@ 'use strict'

if (!opts.secretToken || !opts.userAgent) {
throw new Error('Missing required options: secretToken or userAgent')
}
if (!opts.userAgent) throw new Error('Missing required option: userAgent')
this.secretToken = opts.secretToken
this.secretToken = opts.secretToken || null
this.userAgent = opts.userAgent + ' ' + SUB_USER_AGENT

@@ -40,3 +38,3 @@

headers['Authorization'] = 'Bearer ' + self.secretToken
if (self.secretToken) headers['Authorization'] = 'Bearer ' + self.secretToken
headers['Content-Type'] = 'application/json'

@@ -43,0 +41,0 @@ headers['Content-Encoding'] = 'gzip'

{
"name": "elastic-apm-http-client",
"version": "2.0.1",
"version": "2.1.0",
"description": "A low-level HTTP client for communicating with the Elastic APM intake API",

@@ -38,5 +38,5 @@ "main": "index.js",

"coordinates": [
55.6809998,
12.5644689
55.68104899999999,
12.5644926
]
}

@@ -30,3 +30,2 @@ # elastic-apm-http-client

var client = require('elastic-apm-http-client')({
secretToken: '...',
userAgent: '...'

@@ -51,5 +50,5 @@ })

intake API (default: `false`)
- `secretToken` - The Elastic APM intake API secret token
- `userAgent` - The HTTP user agent that your module should identify it
self with
- `secretToken` - (optional) The Elastic APM intake API secret token

@@ -56,0 +55,0 @@ The init function will return a low level HTTP client primed for

@@ -9,7 +9,2 @@ 'use strict'

var options = {
secretToken: 'secret',
userAgent: 'foo'
}
test('throw if missing required options', function (t) {

@@ -22,2 +17,9 @@ t.throws(function () {

test('only userAgent should be required', function (t) {
t.doesNotThrow(function () {
Client({userAgent: 'foo'})
})
t.end()
})
test('#request()', function (t) {

@@ -34,5 +36,5 @@ var encode = function (body, cb) {

t.test('normal request', function (t) {
var client = Client(options)
var client = Client({secretToken: 'secret', userAgent: 'foo'})
var scope = nock('http://localhost:8080')
.matchHeader('Authorization', 'Bearer ' + options.secretToken)
.matchHeader('Authorization', 'Bearer secret')
.matchHeader('Content-Type', 'application/json')

@@ -57,4 +59,20 @@ .matchHeader('Content-Encoding', 'gzip')

t.test('no secretToken', function (t) {
var client = Client({userAgent: 'foo'})
var scope = nock('http://localhost:8080')
.post('/endpoint')
.reply(function () {
t.ok('content-encoding' in this.req.headers)
t.notOk('authorization' in this.req.headers)
})
client.request('endpoint', body, function (err, res, body) {
t.error(err)
scope.done()
t.end()
})
})
t.test('request with error', function (t) {
var client = Client(options)
var client = Client({userAgent: 'foo'})
var scope = nock('http://localhost:8080')

@@ -77,3 +95,3 @@ .post('/endpoint', function (body) {

t.test('with custom header', function (t) {
var client = Client(options)
var client = Client({userAgent: 'foo'})
var scope = nock('http://localhost:8080')

@@ -80,0 +98,0 @@ .matchHeader('X-Foo', 'bar')

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