Skip to content

Instantly share code, notes, and snippets.

View lluisruscalleda's full-sized avatar

Lluis lluisruscalleda

  • freelance
  • barcelona
View GitHub Profile
# Proxy to an HTTPS server using a PKCS12 client certificate
const fs = require('fs');
const { createProxyMiddleware } = require('http-proxy-middleware');
const apiProxy = createProxyMiddleware('/api', {
target: {
protocol: 'https:',
host: 'example.org',
port: 443,
pfx: fs.readFileSync('path/to/certificate.p12'),
@lluisruscalleda
lluisruscalleda / sumObjs.js
Last active March 5, 2020 15:16
Sum values from an array of objects with the same keys in javascript
export const sumObjs = (...objs) => Object.assign({},
...objs.reduce((acc, obj) => Object.keys(obj).map((key) => {
const ret = {}; ret[key] = acc[key] + obj[key];
return ret;
})));