Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quasar-app-extension-api-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quasar-app-extension-api-wrapper - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

6

package.json
{
"name": "quasar-app-extension-api-wrapper",
"version": "0.0.7",
"description": "A Quasar App Extension",
"version": "0.0.8",
"description": "A Quasar App Extension designed to wrap up the most common features of an api client implementation",
"author": "Roberto <roberto.langarica@gmail.com>",

@@ -23,4 +23,4 @@ "license": "MIT",

"dependencies": {
"api-client-wrapper": ">= 0.0.8"
"api-client-wrapper": ">= 0.1.0"
}
}

@@ -42,3 +42,3 @@ ### Quasar App Extension

```bash
quasar ext remove my-ext <- change name
quasar ext remove api-wrapper
```

@@ -53,3 +53,3 @@

//or
this.$api.get('path').then(result->{});
this.$api.get('path').then(result=>{});
```

@@ -62,3 +62,3 @@

//or
this.$api.post('path', {data}).then(result->{});
this.$api.post('path', {data}).then(result=>{});
```

@@ -73,4 +73,7 @@

delete(path='', conf = {})
//Or the global method that receive a request Configuration
call({request configuration})
```
Note that each method has a final argument that is a custom configuration for the request, this configuration takes precedence over the global configuration. For the supported properties please refer to the _Configuration_ section.
Note that each method has a final argument that is a custom configuration for the request, this configuration takes precedence over the global configuration. For the supported properties please refer to the _Request Configuration_ section.

@@ -91,4 +94,108 @@ ### Bulk calls

#### Params:
* **[paths or configs]:[]**-> An array containing the paths for each request or an array of configuration objects (described next).
* **[paths or configs]:[]**-> An array containing the paths for each request or an array of request configuration objects (described next).
* **continueWithFailure:Boolean**-> Optional with the default to _false_. **`false`** The request will be considered failed when any of it subrequests fail and it will stop any further execution (there could be some sub-requests that never get executed if some other request failed before). **`true`** All the requests are executed, it doesn´t matter if some of them failed.
* **onProgress:Function(progress:Number)**-> Is an optional callback that receives progress between [0-1], the progress is computed with the next formula: _(request-completed / total-amount-of-request-in-the-bulkCall)_
### Request Configuration
A configuration object for each request (with precedence over any global configuration) with the next scheme:
```javascript
{
// Relative or absolute path for the call. Always needed except for when a path was already passed as an argument
url:String,
// The HTTP verb to be used for the request
method:String,
// the URL parameters to be sent with the request
params:{},
// Data to be sent as the request body
data:{},
// An alias to be added to the response of this request for better indentification with bulk calls
alias:String,
// Number of attemps for the request in case of timeout failure
attempts:1,
// Number of milliseconds before the request times out.
timeout:10000
// Any other property supported by axios configuration
...
}
```
It is possible to add any property supported by [axios](https://github.com/axios/axios) (like headers or encoding).
### Response Scheme
For any individual request the response schema is:
```javascript
{
// Present only when an alias was passed in the config for the request
alias:String,
// true: when the status of the request is between [200-300)
// flase: for any status not in the range of 200's
success:Boolean,
// Number of attemps made by this request before being considered completed
attempts:0,
// Any data returned in the response or an array of responses in the case of a bulk call
data:{}
// The error message present when an error is returned with the response
info:"",
// The error instance present in the response (if there is one)
error:null,
// All the other data present in the axios response
...
}
```
In the case of a bulk call the response _data_ is an Array containing the response for each request (in the same order that the requests where passed)
```javascript
let result = await anyBulkCall([{configs}]
//Result data will contain an array of responses
result.data.forEach(response=>{
console.log (response)
})
// If an alias where provided for any request then that request could be accessed with that alias
let result = await anyBulkCall([{alias:'a',...},{alias:'b',...}]
console.log(result.data.a)
console.log(result.data.b)
```
### Global Configuration
Configuration of the overall behaviour for the extension
```javascript
// `baseURL` will be prepended to any path provided unless the provided path is absolute.
this.$api.baseURL = '';
// The amount of attempts a request will make in the case of a timeout before failing completely
this.$api.maxAttemptsPerCall = 1;
// The amount of concurrent requests that could be executed (when the requests number exceed this amount the requests are enqueue in a waiting mode)
this.$api.simultaneousCalls = 5;
// Specifies the number of milliseconds before a request times out
this.$api.timeout = 10000;
// Sets the default headers for 'Content-Type' for each request
this.$api.setContentType(type = 'application/json')
// Sets the default authorization header: 'Authorization' for each request
this.$api.setAuthorization(token, type = 'Bearer')
// If the store where not provided in the boot phase then it could be passed to the extension using this function
// This will bring the module 'APIwrapper' available and the extension will start updating its state
this.$api.setStore(vuex_instance)
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc