vazhaju-web-extensions

1.0.9 • Public • Published

Usage

The callout is activated by ALT + double click combination.

Installation

API Request flow

In order to use the web plugin you'd need to set up a proxy API endpoint, otherwise the web browser would block requests to https://vazhaju.tj because of CORS security constraints.

Web plugin's apiUrl would have to point at your website's proxy endpoint. The request flow would look like this

web plugin -> your website's search proxy -> web plugin's search API endpoint

How to create a proxy endpoint is described below.

How to install the package from CDN

Include this excerpt in your website's HEAD block.

<script src="https://unpkg.com/vazhaju-web-extensions/dist/web-plugin/web-plugin.js"></script>
<link rel="stylesheet" href="https://unpkg.com/vazhaju-web-extensions/dist/web-plugin/web-plugin.css">

<script type="text/javascript">
  VazhajuWebPlugin.configure({
    apiUrl: '/api/search-proxy',
  });
</script>

How to install the package from NPM

Install the package.

npm i vazhaju-web-extensions --save

Import the js and css assets into your code.

// JavaScript
import VazhajuWebPlugin from 'vazhaju-web-extensions/dist/web-plugin/web-plugin';

VazhajuWebPlugin.configure({
  apiUrl: '/api/search-proxy',
});
// Sass / Scss
@import 'vazhaju-web-extensions/dist/web-plugin/web-plugin';

API proxy setup

The proxy should forward web plugin's request to https://vazhaju.tj/api/search/web-plugin.

NodeJS example

router.post('/api/search-proxy', async (req, res, next) => {
  try {
    const response = await axios.post('https://vazhaju.tj/api/search/web-plugin', req.body);

    res.json(response.data);
  } catch (error) {
    next(error);
  }
});

ToDo

  • PHP example
  • Python example
  • C# example

Package Sidebar

Install

npm i vazhaju-web-extensions

Weekly Downloads

1

Version

1.0.9

License

none

Unpacked Size

72 kB

Total Files

6

Last publish

Collaborators

  • maqduni