xible-registry-wrapper
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -68,4 +68,12 @@ module.exports = function(XIBLE_REGISTRY_WRAPPER) { | ||
let req = new OoHttpRequest('GET', `${XIBLE_REGISTRY_WRAPPER.url}/nodepacks/${encodeURI(nodePackName)}`); | ||
return req.toObject(NodePack); | ||
return req.toObject(NodePack) | ||
.catch((err) => { | ||
if (err.statusCode === 404) { | ||
return Promise.resolve(null); | ||
} else { | ||
return Promise.reject(err); | ||
} | ||
}); | ||
} | ||
@@ -84,2 +92,9 @@ | ||
static publish(obj, userToken) { | ||
let req = new OoHttpRequest('POST', `${XIBLE_REGISTRY_WRAPPER.url}/nodepacks?token=${encodeURIComponent(userToken)}`); | ||
return req.toJson(obj); | ||
} | ||
} | ||
@@ -86,0 +101,0 @@ |
{ | ||
"name": "xible-registry-wrapper", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "nodejs wrapper for a xible registry", | ||
@@ -8,6 +8,6 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "https://github.com/spectrumbroad/xibleRegistryWrapper" | ||
"url": "https://github.com/spectrumbroad/xible-registry-wrapper" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/spectrumbroad/xibleRegistryWrapper/issues" | ||
"url": "https://github.com/spectrumbroad/xible-registry-wrapper/issues" | ||
}, | ||
@@ -14,0 +14,0 @@ "keywords": [ |
55
User.js
@@ -15,7 +15,7 @@ module.exports = function(XIBLE_REGISTRY_WRAPPER) { | ||
/** | ||
* adds a user to the registry. rejects if the user already exists | ||
* @param {User} user the user to add | ||
* @returns {Promise} a promise that resolves with a token | ||
*/ | ||
/** | ||
* adds a user to the registry. rejects if the user already exists | ||
* @param {User} user the user to add | ||
* @returns {Promise} a promise that resolves with a token | ||
*/ | ||
static add(user) { | ||
@@ -28,32 +28,39 @@ | ||
/** | ||
* resolves a user for a token, or null if the token can't be matched | ||
* @param {String} token the authentication token belonging to the user | ||
* @returns {Promise} a promise that resolves with the found user or null | ||
*/ | ||
/** | ||
* resolves a user for a token, or null if the token can't be matched | ||
* @param {String} token the authentication token belonging to the user | ||
* @returns {Promise} a promise that resolves with the found user or null | ||
*/ | ||
static getByToken(token) { | ||
let req = new OoHttpRequest('GET', `${XIBLE_REGISTRY_WRAPPER.url}/users?token=${encodeURIComponent(token)}`); | ||
return req.toObject(User); | ||
return req.toObject(User) | ||
.catch((err) => { | ||
if (err.statusCode === 404) { | ||
return Promise.resolve(null); | ||
} else { | ||
return Promise.reject(err); | ||
} | ||
}); | ||
} | ||
/** | ||
* resolves with a token. requires "user.password" to be set | ||
* @returns {Promise} a promise that resolves with the token | ||
*/ | ||
getToken() { | ||
/** | ||
* resolves with a token. requires "user.password" to be set | ||
* @returns {Promise} a promise that resolves with the token | ||
*/ | ||
getToken() { | ||
if(!this.password) { | ||
return Promise.reject(`No "password" set.`); | ||
} | ||
if (!this.password) { | ||
return Promise.reject(`No "password" set.`); | ||
} | ||
if(!this.name) { | ||
return Promise.reject(`No "name" set.`); | ||
} | ||
if (!this.name) { | ||
return Promise.reject(`No "name" set.`); | ||
} | ||
let req = new OoHttpRequest('POST', `${XIBLE_REGISTRY_WRAPPER.url}/users/${encodeURIComponent(this.name)}/token`); | ||
let req = new OoHttpRequest('POST', `${XIBLE_REGISTRY_WRAPPER.url}/users/${encodeURIComponent(this.name)}/token`); | ||
return req.toJson(this); | ||
} | ||
} | ||
@@ -60,0 +67,0 @@ } |
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
4471
127