effects-as-data-http
Advanced tools
Comparing version 0.0.5 to 0.0.7
@@ -0,1 +1,7 @@ | ||
const { merge } = require('./util'); | ||
const defaultHeaders = { | ||
'Content-Type': 'application/json;charset=UTF-8' | ||
}; | ||
function httpGet(url, headers = {}, options = {}) { | ||
@@ -15,3 +21,3 @@ return { | ||
payload, | ||
headers, | ||
headers: merge(defaultHeaders, headers), | ||
options | ||
@@ -26,3 +32,3 @@ }; | ||
payload, | ||
headers, | ||
headers: merge(defaultHeaders, headers), | ||
options | ||
@@ -41,2 +47,9 @@ }; | ||
function rpc(url, fn, payload) { | ||
return httpPost(url, { | ||
fn, | ||
payload | ||
}); | ||
} | ||
module.exports = { | ||
@@ -46,4 +59,5 @@ httpPost, | ||
httpGet, | ||
httpDelete | ||
httpDelete, | ||
rpc | ||
}; | ||
//# sourceMappingURL=actions.js.map |
const { httpGet, httpDelete, httpPost, httpPut } = require('./actions'); | ||
const { deepEqual } = require('assert'); | ||
const defaultHeaders = { | ||
'Content-Type': 'application/json;charset=UTF-8' | ||
}; | ||
describe('actions', () => { | ||
@@ -17,5 +21,5 @@ describe('httpGet', () => { | ||
it('should return an httpGet ', () => { | ||
it('should return an httpGet', () => { | ||
const actual = httpGet('http://www.example.com', { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, { | ||
@@ -29,3 +33,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, | ||
@@ -53,5 +57,5 @@ options: { | ||
it('should return an httpDelete ', () => { | ||
it('should return an httpDelete', () => { | ||
const actual = httpDelete('http://www.example.com', { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, { | ||
@@ -65,3 +69,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, | ||
@@ -84,3 +88,3 @@ options: { | ||
payload: { foo: 'bar' }, | ||
headers: {}, | ||
headers: defaultHeaders, | ||
options: {} | ||
@@ -91,5 +95,5 @@ }; | ||
it('should return an httpPost ', () => { | ||
it.only('should return an httpPost', () => { | ||
const actual = httpPost('http://www.example.com', { foo: 'bar' }, { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, { | ||
@@ -104,3 +108,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, | ||
@@ -123,3 +127,3 @@ options: { | ||
payload: { foo: 'bar' }, | ||
headers: {}, | ||
headers: defaultHeaders, | ||
options: {} | ||
@@ -130,5 +134,5 @@ }; | ||
it('should return an httpPut ', () => { | ||
it('should return an httpPut', () => { | ||
const actual = httpPut('http://www.example.com', { foo: 'bar' }, { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, { | ||
@@ -143,3 +147,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, | ||
@@ -146,0 +150,0 @@ options: { |
{ | ||
"name": "effects-as-data-http", | ||
"version": "0.0.5", | ||
"version": "0.0.7", | ||
"description": "Http for effects-as-data", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -0,1 +1,7 @@ | ||
const { merge } = require('./util') | ||
const defaultHeaders = { | ||
'Content-Type': 'application/json;charset=UTF-8' | ||
} | ||
function httpGet (url, headers = {}, options = {}) { | ||
@@ -15,3 +21,3 @@ return { | ||
payload, | ||
headers, | ||
headers: merge(defaultHeaders, headers), | ||
options | ||
@@ -26,3 +32,3 @@ } | ||
payload, | ||
headers, | ||
headers: merge(defaultHeaders, headers), | ||
options | ||
@@ -41,2 +47,9 @@ } | ||
function rpc (url, fn, payload) { | ||
return httpPost(url, { | ||
fn, | ||
payload | ||
}) | ||
} | ||
module.exports = { | ||
@@ -46,3 +59,4 @@ httpPost, | ||
httpGet, | ||
httpDelete | ||
httpDelete, | ||
rpc | ||
} |
const { httpGet, httpDelete, httpPost, httpPut } = require('./actions') | ||
const { deepEqual } = require('assert') | ||
const defaultHeaders = { | ||
'Content-Type': 'application/json;charset=UTF-8' | ||
} | ||
describe('actions', () => { | ||
@@ -17,5 +21,5 @@ describe('httpGet', () => { | ||
it('should return an httpGet ', () => { | ||
it('should return an httpGet', () => { | ||
const actual = httpGet('http://www.example.com', { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, { | ||
@@ -29,3 +33,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, | ||
@@ -53,5 +57,5 @@ options: { | ||
it('should return an httpDelete ', () => { | ||
it('should return an httpDelete', () => { | ||
const actual = httpDelete('http://www.example.com', { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, { | ||
@@ -65,3 +69,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'application/json' | ||
}, | ||
@@ -84,3 +88,3 @@ options: { | ||
payload: {foo: 'bar'}, | ||
headers: {}, | ||
headers: defaultHeaders, | ||
options: {} | ||
@@ -91,5 +95,5 @@ } | ||
it('should return an httpPost ', () => { | ||
it.only('should return an httpPost', () => { | ||
const actual = httpPost('http://www.example.com', {foo: 'bar'}, { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, { | ||
@@ -104,3 +108,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, | ||
@@ -123,3 +127,3 @@ options: { | ||
payload: {foo: 'bar'}, | ||
headers: {}, | ||
headers: defaultHeaders, | ||
options: {} | ||
@@ -130,5 +134,5 @@ } | ||
it('should return an httpPut ', () => { | ||
it('should return an httpPut', () => { | ||
const actual = httpPut('http://www.example.com', {foo: 'bar'}, { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, { | ||
@@ -143,3 +147,3 @@ credentials: 'include' | ||
headers: { | ||
'Content-type': 'application/json' | ||
'Content-Type': 'text/html' | ||
}, | ||
@@ -146,0 +150,0 @@ options: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42631
792