syncano-server
Advanced tools
Comparing version 0.7.2-12 to 0.7.2-13
@@ -41,2 +41,12 @@ 'use strict'; | ||
}, { | ||
key: 'localFetch', | ||
value: function localFetch(url, token, options) { | ||
return (0, _nodeFetch2.default)(url, _extends({ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-API-KEY': this.instance.token | ||
} | ||
}, options)).then(_utils.checkStatus); | ||
} | ||
}, { | ||
key: 'nonInstanceFetch', | ||
@@ -43,0 +53,0 @@ value: function nonInstanceFetch(url, options, headers) { |
@@ -31,2 +31,6 @@ 'use strict'; | ||
var _endpoint = require('./endpoint'); | ||
var _endpoint2 = _interopRequireDefault(_endpoint); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -56,2 +60,4 @@ | ||
event.instance = instanceConfig; | ||
var endpoint = new _endpoint2.default(); | ||
endpoint.instance = instanceConfig; | ||
@@ -66,2 +72,3 @@ var account = new _account2.default({ accountKey: options.accountKey }); | ||
event: event, | ||
endpoint: endpoint, | ||
data: new Proxy(new _data2.default(), { | ||
@@ -68,0 +75,0 @@ get: function get(target, className) { |
@@ -7,4 +7,17 @@ 'use strict'; | ||
var getHost = exports.getHost = function getHost() { | ||
return process.env.SYNCANO_HOST || 'api.syncano.io'; | ||
try { | ||
return META.api_host; // eslint-disable-line no-undef | ||
} catch (err) { | ||
return process.env.SYNCANO_HOST || 'api.syncano.io'; | ||
} | ||
}; | ||
var getSpaceHost = exports.getSpaceHost = function getSpaceHost() { | ||
try { | ||
return META.space_host; // eslint-disable-line no-undef | ||
} catch (err) { | ||
return process.env.SYNCANO_SPACE_HOST || 'syncano.space'; | ||
} | ||
}; | ||
var SYNCANO_API_VERSION = exports.SYNCANO_API_VERSION = 'v2'; |
@@ -10,2 +10,3 @@ 'use strict'; | ||
exports.buildInstanceURL = buildInstanceURL; | ||
exports.buildLocalInstanceURL = buildLocalInstanceURL; | ||
@@ -39,2 +40,6 @@ var _settings = require('./settings'); | ||
return buildSyncanoURL() + '/instances/' + instanceName; | ||
} | ||
function buildLocalInstanceURL(instanceName) { | ||
return 'https://' + instanceName + '.' + (0, _settings.getSpaceHost)(); | ||
} |
{ | ||
"name": "syncano-server", | ||
"version": "0.7.2-12", | ||
"version": "0.7.2-13", | ||
"description": "A library to intereact with the Syncano API on a server side", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -22,2 +22,13 @@ import nodeFetch from 'node-fetch' | ||
localFetch(url, token, options) { | ||
return nodeFetch(url, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-API-KEY': this.instance.token | ||
}, | ||
...options | ||
}) | ||
.then(checkStatus) | ||
} | ||
nonInstanceFetch(url, options, headers) { | ||
@@ -24,0 +35,0 @@ return nodeFetch(url, { |
@@ -6,2 +6,3 @@ import Data from './data' | ||
import Event from './event' | ||
import Endpoint from './endpoint' | ||
@@ -28,2 +29,4 @@ export default function server(options = {}) { | ||
event.instance = instanceConfig | ||
const endpoint = new Endpoint() | ||
endpoint.instance = instanceConfig | ||
@@ -38,2 +41,3 @@ const account = new Account({accountKey: options.accountKey}) | ||
event, | ||
endpoint, | ||
data: new Proxy(new Data(), { | ||
@@ -40,0 +44,0 @@ get(target, className) { |
export const getHost = function () { | ||
return process.env.SYNCANO_HOST || 'api.syncano.io' | ||
try { | ||
return META.api_host // eslint-disable-line no-undef | ||
} catch (err) { | ||
return process.env.SYNCANO_HOST || 'api.syncano.io' | ||
} | ||
} | ||
export const getSpaceHost = function () { | ||
try { | ||
return META.space_host // eslint-disable-line no-undef | ||
} catch (err) { | ||
return process.env.SYNCANO_SPACE_HOST || 'syncano.space' | ||
} | ||
} | ||
export const SYNCANO_API_VERSION = 'v2' |
@@ -1,2 +0,2 @@ | ||
import {getHost, SYNCANO_API_VERSION} from './settings' | ||
import {getHost, getSpaceHost, SYNCANO_API_VERSION} from './settings' | ||
@@ -29,1 +29,5 @@ export function checkStatus(response) { | ||
} | ||
export function buildLocalInstanceURL(instanceName) { | ||
return `https://${instanceName}.${getSpaceHost()}` | ||
} |
Sorry, the diff of this file is not supported yet
493086
50
1812
5
14