Socket
Socket
Sign inDemoInstall

@advanced-rest-client/arc-request-logic

Package Overview
Dependencies
6
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @advanced-rest-client/arc-request-logic

A request logic for Advanced REST Client excluding HTTP transport.


Version published
Maintainers
1
Install size
1.25 MB
Created

Changelog

Source

3.0.3 (2020-01-08)

Build

  • bumping version b558b71 by Pawel
  • bumping version c524a51 by Pawel Psztyc
  • bumping version ce8e394 by Pawel Psztyc

Update

  • updating dependencies f4eb35c by Pawel
  • [ci skip] automated merge master->stage. syncing main branches dd3d10e by Ci agent
  • updating dependencies 0bc910d by Pawel Psztyc
  • [ci skip] automated merge master->stage. syncing main branches 0081b61 by Ci agent

Bug Fixes

  • fixing removing items from responseActions array 10cd46f by Pawel
  • making client-certificate-get event composed c7d8f4c by Pawel Psztyc
  • fixing basic authorization setup ceb5aed by Pawel Psztyc

Readme

Source

Published on NPM

Build Status

arc-request-logic

A request logic for Advanced REST Client excluding HTTP transport.

This component is responsible for handing api-request event, handing variables processing, request actions, before-request event, dispatching URL history store event, communicating with transport library, and finally dispatching api-response event. If the transport library it the hearth of the application then this component is it's brain.

API components

This components is a part of API components ecosystem

Usage

Installation

npm install --save @advanced-rest-client/arc-request-logic

Jexl dependency

This library uses @advanced-rest-client/arc-request-logic which depend on Jexl and this library is not included by default in the element. You need to add this dependency manually.

You must install Jexl on your project, and build it for browser. See dev-lib/ folder for an example of such a build.

Finally you have to either pass the pointer to Jexl library to jexl property or point to a relative in the window object.

Setting Jexl reference:

const eval = document.querySelector('arc-request-logic');
eval.jexl = myJexlVariable;

Setting path to Jexl:

<arc-request-logic jexlpath="ArcVariables.JexlDev"></arc-request-logic>

This expects the Jexl library to be under window.ArcVariables.JexlDev variable.

development

git clone https://github.com/advanced-rest-client/arc-request-logic
cd arc-request-logic
npm install

Running the tests

npm test

Middleware

Handle before-request custom event to alter request properties before send. When the handler is synchronous then there's no need for additional steps.

If the handler is asynchronous then add a Promise to the promises array on detail object and resolve it when ready. It is possible to set timeout property on the promise to extend default timeout for before-request event processing which is set to 2000ms.

document.body.addEventListener('before-request', (e) => {
  cont p = new Promise((resolve) => {
    sync processUrl(e.detail); // set new URL on the detail object as objects are passed by reference
    resolve();
  });
  p.timeout = 3500;
  e.detail.promises.push(p);
});

document.body.dispatchEvent(new CustomEvent('api-request', {
  bubbles: true,
  cancelable: true,
  detail: request
});

Mind that other handlers may interact with the same properties. Even though there's no race conditions per so in JavaScript you may get different values between processing different parts of request if the event loop is releases.

Keywords

FAQs

Last updated on 08 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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