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

@tailored-apps/api-connector

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tailored-apps/api-connector - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

CHANGELOG.md
# Changelog
## 2018-04-04
* `[SEMVER_MINOR]` added `formData` property to request specs. Set to `true` if you want request payload to be sent as `form-data` rather than `application/json`
* `[SEMVER_MINOR]` added `bodyProp` option to request spec. This allows you to specify the property name used for sending the request body (defaults to `body`, can be set to any other value that the `request` library supports, e.g. `form` or `formData`)
## 2017-11-29
* Initial release as a standalone module

@@ -38,3 +38,3 @@ const deepmerge = require('deepmerge')

function getRequestSpec (baseUrl, endpoint, params) {
const { route, method, doReplace, getPath, getQuery, getBody, formData = false, json = true } = endpoint // default to json = true for all endpoints
const { route, method, doReplace, getPath, getQuery, getBody, bodyProp = 'body', json = true } = endpoint // default to json = true for all endpoints

@@ -48,3 +48,2 @@ const canHaveBody = method === METHOD_PATCH || method === METHOD_POST || method === METHOD_PUT

const body = canHaveBody ? (getBody ? getBody(params) : params) : undefined
const form = canHaveBody && formData ? body : undefined

@@ -56,5 +55,4 @@ return Object.assign({ }, endpoint, {

qs,
form,
body: body && !formData ? body : undefined,
json: formData ? false : json
json,
[bodyProp]: body
})

@@ -61,0 +59,0 @@ }

{
"name": "@tailored-apps/api-connector",
"version": "1.1.0",
"version": "1.2.0",
"description": "A small library providing various utility functions used in tailored apps backends (propably not very useful for anyone else)",

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

@@ -72,9 +72,8 @@ /* eslint-env mocha */

it('uses "form" property instead of body if specified', function () {
it('allows a custom body property name to be specified', function () {
const params = { a: 'b', c: 'd' }
const spec = getSpec({ route: '/form', method: METHOD_POST, formData: true }, params)
const spec = getSpec({ route: '/form', method: METHOD_POST, bodyProp: 'formData' }, params)
expect(spec.body).to.equal(undefined)
expect(spec.json).to.equal(false)
expect(spec.form).to.deep.equal(params)
expect(spec.formData).to.deep.equal(params)
})

@@ -81,0 +80,0 @@

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