syncano-server
Advanced tools
Comparing version 0.8.1-1 to 0.8.1-2
@@ -61,4 +61,4 @@ 'use strict'; | ||
}; | ||
fetch(_this2.url(), {}, headers).then(function (resp) { | ||
return resolve(resp); | ||
fetch(_this2.url(), {}, headers).then(function (res) { | ||
return resolve(res); | ||
}).catch(function (err) { | ||
@@ -65,0 +65,0 @@ return reject(err); |
@@ -13,2 +13,6 @@ 'use strict'; | ||
var _formData = require('form-data'); | ||
var _formData2 = _interopRequireDefault(_formData); | ||
var _queryBuilder = require('./query-builder'); | ||
@@ -447,6 +451,12 @@ | ||
value: function create(body) { | ||
return this.fetch(this.url(), { | ||
var headers = null; | ||
var params = { | ||
method: 'POST', | ||
body: JSON.stringify(body) | ||
}); | ||
}; | ||
if (body instanceof _formData2.default) { | ||
params.body = body; | ||
headers = body.getHeaders(); | ||
} | ||
return this.fetch(this.url(), params, headers); | ||
} | ||
@@ -453,0 +463,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.data = exports.response = exports.logger = exports.socket = exports.event = exports.channel = exports.instance = exports.account = exports.users = undefined; | ||
exports._class = exports.data = exports.response = exports.logger = exports.socket = exports.event = exports.channel = exports.instance = exports.account = exports.users = undefined; | ||
@@ -24,3 +24,4 @@ var _server = require('./server'); | ||
response = _ref.response, | ||
data = _ref.data; | ||
data = _ref.data, | ||
_class = _ref._class; | ||
@@ -36,2 +37,3 @@ exports.users = users; | ||
exports.data = data; | ||
exports._class = _class; | ||
exports.default = _server2.default; |
@@ -33,7 +33,11 @@ 'use strict'; | ||
value: function fetch(url, options) { | ||
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var headersToSend = Object.assign({ | ||
'content-type': 'application/json', | ||
'x-api-key': this.instance.token | ||
}, headers); | ||
return (0, _nodeFetch2.default)(url, _extends({ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-API-KEY': this.instance.token | ||
} | ||
headers: headersToSend | ||
}, options)).then(_utils.checkStatus).then(_utils.parseJSON); | ||
@@ -46,3 +50,3 @@ } | ||
headers: _extends({ | ||
'Content-Type': 'application/json' | ||
'content-type': 'application/json' | ||
}, headers) | ||
@@ -49,0 +53,0 @@ }, options)).then(_utils.checkStatus).then(_utils.parseJSON); |
@@ -43,2 +43,6 @@ 'use strict'; | ||
var _class2 = require('./class'); | ||
var _class3 = _interopRequireDefault(_class2); | ||
var _settings = require('./settings'); | ||
@@ -74,2 +78,4 @@ | ||
socket.instance = instanceConfig; | ||
var _class = new _class3.default(); | ||
_class.instance = instanceConfig; | ||
@@ -86,2 +92,3 @@ var account = new _account2.default({ accountKey: options.accountKey }); | ||
socket: socket, | ||
_class: _class, | ||
logger: _logger2.default, | ||
@@ -88,0 +95,0 @@ response: _response2.default, |
{ | ||
"name": "syncano-server", | ||
"version": "0.8.1-1", | ||
"version": "0.8.1-2", | ||
"description": "A library to intereact with the Syncano API on a server side", | ||
@@ -28,2 +28,3 @@ "main": "lib/index.js", | ||
"e2e": "mkdir e2e-tests || true && cross-env NODE_ENV=test mocha tests/e2e/*.js --reporter spec --require babel-register --timeout 30000 --slow 8000", | ||
"e2e:single": "mkdir e2e-tests || true && cross-env NODE_ENV=test mocha --reporter spec --require babel-register --timeout 30000 --slow 8000", | ||
"watch": "npm-run-all --parallel watch:*", | ||
@@ -44,2 +45,3 @@ "watch:lib": "npm run build:lib -- --watch", | ||
"dependencies": { | ||
"form-data": "^2.1.4", | ||
"node-fetch": "2.0.0-alpha.3" | ||
@@ -46,0 +48,0 @@ }, |
@@ -28,3 +28,3 @@ import QueryBuilder from './query-builder' | ||
fetch(this.url(), {}, headers) | ||
.then(resp => resolve(resp)) | ||
.then(res => resolve(res)) | ||
.catch(err => reject(err)) | ||
@@ -31,0 +31,0 @@ }) |
import querystring from 'querystring' | ||
import FormData from 'form-data' | ||
import QueryBuilder from './query-builder' | ||
@@ -362,6 +363,12 @@ import {NotFoundError} from './errors' | ||
create(body) { | ||
return this.fetch(this.url(), { | ||
let headers = null | ||
const params = { | ||
method: 'POST', | ||
body: JSON.stringify(body) | ||
}) | ||
} | ||
if (body instanceof FormData) { | ||
params.body = body | ||
headers = body.getHeaders() | ||
} | ||
return this.fetch(this.url(), params, headers) | ||
} | ||
@@ -368,0 +375,0 @@ |
@@ -12,5 +12,6 @@ import Server from './server' | ||
response, | ||
data | ||
data, | ||
_class | ||
} = new Server() | ||
export default Server |
@@ -10,8 +10,10 @@ import nodeFetch from 'node-fetch' | ||
fetch(url, options) { | ||
fetch(url, options, headers = {}) { | ||
const headersToSend = Object.assign({ | ||
'content-type': 'application/json', | ||
'x-api-key': this.instance.token | ||
}, headers) | ||
return nodeFetch(url, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-API-KEY': this.instance.token | ||
}, | ||
headers: headersToSend, | ||
...options | ||
@@ -26,3 +28,3 @@ }) | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'content-type': 'application/json', | ||
...headers | ||
@@ -29,0 +31,0 @@ }, |
@@ -10,2 +10,3 @@ import Data from './data' | ||
import Channel from './channel' | ||
import Class from './class' | ||
import { | ||
@@ -43,2 +44,4 @@ getToken, | ||
socket.instance = instanceConfig | ||
const _class = new Class() | ||
_class.instance = instanceConfig | ||
@@ -55,2 +58,3 @@ const account = new Account({accountKey: options.accountKey}) | ||
socket, | ||
_class, | ||
logger: Logger, | ||
@@ -57,0 +61,0 @@ response: Response, |
@@ -0,2 +1,4 @@ | ||
/* eslint-disable no-unused-expressions */ | ||
import {expect} from 'chai' | ||
import Server from '../../src' | ||
@@ -46,3 +48,3 @@ import {getRandomString, createTestInstance, deleteTestInstance} from '../utils' | ||
.then(event => { | ||
expect(event).to.be.empty // eslint-disable-line no-unused-expressions | ||
expect(event).to.be.empty | ||
done() | ||
@@ -59,3 +61,3 @@ }) | ||
.then(event => { | ||
expect(event).to.be.empty // eslint-disable-line no-unused-expressions | ||
expect(event).to.be.empty | ||
done() | ||
@@ -62,0 +64,0 @@ }) |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-unused-expressions */ | ||
import {expect} from 'chai' | ||
@@ -30,4 +31,4 @@ | ||
instance.delete(testInstanceName) | ||
.then(resp => { | ||
expect(resp).to.be.empty // eslint-disable-line no-unused-expressions | ||
.then(res => { | ||
expect(res).to.be.empty | ||
done() | ||
@@ -34,0 +35,0 @@ }) |
@@ -37,3 +37,2 @@ import {getRandomString, createTestInstance, deleteTestInstance} from '../utils' | ||
// .then(data => { | ||
// console.log("XXX", data) | ||
// done() | ||
@@ -40,0 +39,0 @@ // }) |
@@ -17,5 +17,5 @@ import should from 'should/as-function' | ||
const {socket, signal} = Event._splitSignal(`${signalName}`) | ||
should(socket).be.undefined; | ||
should(socket).be.undefined | ||
should(signal).be.equal(signalName) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
812950
65
3176
2
14
18
+ Addedform-data@^2.1.4
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@2.5.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedsafe-buffer@5.2.1(transitive)