Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@spinque/query-api

Package Overview
Dependencies
10
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.2.3

39

dist/Api.js

@@ -68,5 +68,5 @@ "use strict";

if (apiConfig && apiConfig.authentication) {
// if (isBrowser && apiConfig.authentication.type === 'client-credentials') {
// throw new Error('The Client Credentials Flow is only allowed for server application.');
// }
if (browser_or_node_1.isBrowser && apiConfig.authentication.type === 'client-credentials') {
throw new Error('The Client Credentials Flow is only allowed for server application.');
}
this._authentication = apiConfig.authentication;

@@ -189,22 +189,21 @@ }

return __awaiter(this, void 0, void 0, function () {
var json, json;
var json;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(response.status === 200)) return [3 /*break*/, 2];
return [4 /*yield*/, response.json()];
case 1: return [2 /*return*/, (_a.sent())];
case 2:
if (!(response.status === 401)) return [3 /*break*/, 4];
return [4 /*yield*/, response.json()];
case 3:
case 0: return [4 /*yield*/, response.json()];
case 1:
json = _a.sent();
throw new types_1.UnauthorizedError(json.message, 401);
case 4:
if (!(response.status === 500)) return [3 /*break*/, 6];
return [4 /*yield*/, response.json()];
case 5:
json = _a.sent();
throw new types_1.ServerError(json.message, 401);
case 6: throw new types_1.ErrorResponse('Unknown response', response.status);
if (response.status === 200) {
return [2 /*return*/, json];
}
if (response.status === 401) {
throw new types_1.UnauthorizedError(json.message, 401);
}
if (response.status === 400 && json.message.startsWith('no endpoint')) {
throw new types_1.EndpointNotFoundError(json.message, 400);
}
if (response.status === 500) {
throw new types_1.ServerError(json.message, 401);
}
throw new types_1.ErrorResponse('Unknown error: ' + (json.message || ''), response.status);
}

@@ -211,0 +210,0 @@ });

@@ -52,2 +52,7 @@ export interface ApiConfig {

}
export declare class EndpointNotFoundError implements ErrorResponse {
message: string;
status: number;
constructor(message: string, status: number);
}
export declare class UnauthorizedError implements ErrorResponse {

@@ -54,0 +59,0 @@ message: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerError = exports.UnauthorizedError = exports.ErrorResponse = void 0;
exports.ServerError = exports.UnauthorizedError = exports.EndpointNotFoundError = exports.ErrorResponse = void 0;
var ErrorResponse = /** @class */ (function () {

@@ -13,2 +13,11 @@ function ErrorResponse(message, status) {

// tslint:disable-next-line: max-classes-per-file
var EndpointNotFoundError = /** @class */ (function () {
function EndpointNotFoundError(message, status) {
this.message = message;
this.status = status;
}
return EndpointNotFoundError;
}());
exports.EndpointNotFoundError = EndpointNotFoundError;
// tslint:disable-next-line: max-classes-per-file
var UnauthorizedError = /** @class */ (function () {

@@ -15,0 +24,0 @@ function UnauthorizedError(message, status) {

{
"name": "@spinque/query-api",
"version": "0.2.2",
"version": "0.2.3",
"description": "",

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

# @spinque/query-api
TypeScript library to use the Spinque Query API in your project.
JavaScript/TypeScript library to use the Spinque Query API in your project.

@@ -67,1 +67,25 @@ ## Usage

### Vanilla JavaScript
This library can also be used without using TypeScript:
```javascript
const sqa = require("@spinque/query-api");
const api = new sqa.Api({
workspace: 'my-workspace',
api: 'movies'
});
const query = {
endpoint: 'search',
parameters: { term: 'utrecht' }
};
try {
const results = await api.fetch(query);
console.log(results);
} catch (error) {
console.log(error);
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc