syncano-server
Advanced tools
Comparing version 0.7.1 to 0.7.2-0
@@ -0,0 +0,0 @@ { |
@@ -19,2 +19,4 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -50,3 +52,3 @@ | ||
var url = 'https://api.syncano.rocks/v2/instances/' + instanceName + '/classes/' + className + '/objects/' + (id ? id + '/' : ''); | ||
var url = (0, _utils.buildInstanceURL)(instanceName) + '/classes/' + className + '/objects/' + (id ? id + '/' : ''); | ||
var query = _querystring2.default.stringify(this.query); | ||
@@ -53,0 +55,0 @@ |
@@ -17,2 +17,4 @@ 'use strict'; | ||
var _settings = require('./settings'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
this.baseUrl = 'https://api.syncano.rocks'; | ||
this.baseUrl = 'https://' + _settings.SYNCANO_HOST; | ||
} | ||
@@ -43,2 +45,13 @@ | ||
}, { | ||
key: 'nonInstanceFetch', | ||
value: function nonInstanceFetch(url, options, headers) { | ||
var request = (0, _nodeFetch2.default)(url, _extends({ | ||
headers: _extends({ | ||
'Content-Type': 'application/json' | ||
}, headers) | ||
}, options)).then(_utils.checkStatus).then(_utils.parseJSON); | ||
return request; | ||
} | ||
}, { | ||
key: 'withQuery', | ||
@@ -45,0 +58,0 @@ value: function withQuery(query) { |
@@ -19,2 +19,6 @@ 'use strict'; | ||
var _account = require('./account'); | ||
var _account2 = _interopRequireDefault(_account); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -41,4 +45,7 @@ | ||
var account = new _account2.default(); | ||
return { | ||
users: users, | ||
account: account, | ||
data: new Proxy(new _data2.default(), { | ||
@@ -45,0 +52,0 @@ get: function get(target, className) { |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -8,2 +8,7 @@ Object.defineProperty(exports, "__esModule", { | ||
exports.parseJSON = parseJSON; | ||
exports.buildSyncanoURL = buildSyncanoURL; | ||
exports.buildInstanceURL = buildInstanceURL; | ||
var _settings = require('./settings'); | ||
function checkStatus(response) { | ||
@@ -23,2 +28,10 @@ if (response.status >= 200 && response.status < 300) { | ||
return response.json(); | ||
} | ||
function buildSyncanoURL() { | ||
return 'https://' + _settings.SYNCANO_HOST + '/' + _settings.SYNCANO_API_VERSION; | ||
} | ||
function buildInstanceURL(instanceName) { | ||
return buildSyncanoURL() + '/instances/' + instanceName; | ||
} |
{ | ||
"name": "syncano-server", | ||
"version": "0.7.1", | ||
"version": "0.7.2-0", | ||
"description": "A library to intereact with the Syncano API on a server side", | ||
@@ -19,3 +19,7 @@ "main": "lib/index.js", | ||
"prebuild": "npm run clean", | ||
"test": "mocha test/**/*.js --compilers js:babel-register", | ||
"report-coverage": "cat ./coverage/lcov.info | codecov", | ||
"unit": "cross-env NODE_ENV=test mocha 'test/**/*.js' --reporter spec --require babel-register", | ||
"test": "npm-run-all --parallel test:unit", | ||
"test:unit": "cross-env NODE_ENV=test nyc yarn run unit", | ||
"lint": "xo src/**/*.js", | ||
"test:coverage": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
@@ -25,5 +29,8 @@ "watch": "npm-run-all --parallel watch:*", | ||
"watch:lib:test": "mocha --watch test/**/*.js --compilers js:babel-register", | ||
"release": "npm-run-all release:*", | ||
"release:docs": "gh-pages -d docs -m \"Docs v${npm_package_version} [ci skip]\"", | ||
"release:reset": "git reset --hard $CIRCLE_SHA1" | ||
"release:reset": "git reset --hard $CIRCLE_SHA1", | ||
"release:git-config": "git config --global user.email $GITHUB_EMAIL && git config --global user.name $GITHUB_NAME", | ||
"release:npm-token": "echo \"//registry.npmjs.org/:_authToken=${NPM_TOKEN}\nprogress=false\" > ~/.npmrc", | ||
"release:beta": "npm version prerelease -m \"Bump to %s [ci skip]\" && git push origin $CIRCLE_BRANCH", | ||
"release": "npm version patch -m \"Bump to %s [ci skip]\" && git push origin $CIRCLE_BRANCH" | ||
}, | ||
@@ -47,2 +54,3 @@ "repository": { | ||
"codecov": "^1.0.1", | ||
"cross-env": "^3.1.4", | ||
"eslint": "^1.10.3", | ||
@@ -49,0 +57,0 @@ "gh-pages": "^0.11.0", |
import querystring from 'querystring' | ||
import QueryBuilder from './query-builder' | ||
import {NotFoundError} from './errors' | ||
import {buildInstanceURL} from './utils' | ||
/** | ||
@@ -12,3 +12,3 @@ * Syncano server | ||
const {instanceName, className} = this.instance | ||
const url = `https://api.syncano.rocks/v2/instances/${instanceName}/classes/${className}/objects/${id ? id + '/' : ''}` | ||
const url = `${buildInstanceURL(instanceName)}/classes/${className}/objects/${id ? id + '/' : ''}` | ||
const query = querystring.stringify(this.query) | ||
@@ -15,0 +15,0 @@ |
import nodeFetch from 'node-fetch' | ||
import {checkStatus, parseJSON} from './utils' | ||
import {SYNCANO_HOST} from './settings' | ||
export default class QueryBuilder { | ||
constructor() { | ||
this.baseUrl = 'https://api.syncano.rocks' | ||
this.baseUrl = `https://${SYNCANO_HOST}` | ||
} | ||
@@ -23,2 +24,16 @@ | ||
nonInstanceFetch(url, options, headers) { | ||
const request = nodeFetch(url, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
...headers | ||
}, | ||
...options | ||
}) | ||
.then(checkStatus) | ||
.then(parseJSON) | ||
return request | ||
} | ||
get query() { | ||
@@ -25,0 +40,0 @@ return this._query || {} |
import Data from './data' | ||
import Users from './users' | ||
import Account from './account' | ||
@@ -21,4 +22,7 @@ export default function server(options = {}) { | ||
const account = new Account() | ||
return { | ||
users, | ||
account, | ||
data: new Proxy(new Data(), { | ||
@@ -25,0 +29,0 @@ get(target, className) { |
@@ -0,1 +1,3 @@ | ||
import {SYNCANO_HOST, SYNCANO_API_VERSION} from './settings' | ||
export function checkStatus(response) { | ||
@@ -16,1 +18,9 @@ if (response.status >= 200 && response.status < 300) { | ||
} | ||
export function buildSyncanoURL() { | ||
return `https://${SYNCANO_HOST}/${SYNCANO_API_VERSION}` | ||
} | ||
export function buildInstanceURL(instanceName) { | ||
return `${buildSyncanoURL()}/instances/${instanceName}` | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
254065
31
923
22
7