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

@tipe/databox-loader

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tipe/databox-loader - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "@tipe/databox-loader",
"version": "0.0.2",
"version": "0.0.3",
"description": "Tipe Databox Loader for talking with Databox",

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

@@ -30,2 +30,14 @@ const fetch = require('node-fetch')

function databoxFetch(url, model, action, body) {
return fetch(`${url}/api/${model}/${action}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: body
})
})
.then(resp => resp.json())
}
module.exports = function createDatabox(url, _models, _actions) {

@@ -36,15 +48,8 @@ _models = _models || models

_models.forEach(model => {
orm[model] = orm[model] || {}
if (orm[model] === undefined) {
orm[model] = {}
}
_actions.forEach(action => {
orm[model][action] = function databoxFetch(body) {
return fetch(`${url}/api/${model}/${action}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: body
})
})
.then(resp => resp.json())
if (orm[model][action] === undefined) {
orm[model][action] = databoxFetch.bind(url, model, action)
}

@@ -64,4 +69,7 @@ })

{
data: {},
errors: []
}
*/

@@ -13,10 +13,8 @@ const createDatabox = require('./create');

[
'action'
'action',
'action2'
])
});
// afterEach(() => {
// });
test('creates obj', () => {
console.log('databox', databox)
expect(databox.hasOwnProperty('testing')).toBe(true);

@@ -27,2 +25,12 @@ expect(databox.hasOwnProperty('testing1')).toBe(true);

});
test('creates obj with actions', () => {
expect(databox.testing.hasOwnProperty('action')).toBe(true);
expect(databox.testing.hasOwnProperty('action2')).toBe(true);
expect(databox.testing1.hasOwnProperty('action')).toBe(true);
expect(databox.testing1.hasOwnProperty('action2')).toBe(true);
expect(databox.testing2.hasOwnProperty('action')).toBe(true);
expect(databox.testing2.hasOwnProperty('action2')).toBe(true);
expect(databox.testing3.hasOwnProperty('action')).toBe(true);
expect(databox.testing3.hasOwnProperty('action2')).toBe(true);
});
})
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