bigesdk

bige's apim software development kit package

Usage no npm install needed!

<script type="module">
  import bigesdk from 'https://cdn.skypack.dev/bigesdk';
</script>

README

WARNING

This project is currentcly under development and this version is dedicated to our devs tests.

To understand BSDK please visit http://apim.bige.dev/about/BSDK We believe that the first usable version will only be available in a few months.

BSDK by bige 1.0.7

1.0.7 integrate websockets that allow you to remote fractions in your app. that's dedicated to developpers who want to check and track API consumption, costs and more.

We are working on 1.0.8...

waiting for 1.0.8 that will alllow you to enable or disable dependencies. Actually the BSDK lib feel a bit strong sized also you can use it to enable others sockets and axios requests in your app.

const APIM = new BSDK("your_api_key");
APIM.axios.get(...)
APIM.io('socket.io lib')

There lib intergration ensure that BSDK work correctly...

axios size : 371Ko socket.io size : 941Ko until BSDK size with reduced libraries : 677 Ko. true BSDK size : ~12Ko

note that socket.io is integrated while waiting for a more efficient socket. when the apis will be integrated on APIM socket.io should disappear in favor of a new distributed base. currently socket.io is present to overcome this expectation

BSDK by bige 1.0.6

This developpement kit is dedicated to APIM by bige applications its simplify the access to any declared APIs on https://apim.bige.dev.

BSDK allow your application to consume any public or private APIs from apim.bige.dev proxy gateway. to consume API, your application will be authorized by the API maintainer from APIs request on your appboard.

About APIM

Apim is a gateway with application access security setup that allow youu to declare and access your APIs by a single line from BSDK.

Install BSDK

npm i bigesdk@latest --save

You can visit the soon project page here http://apim.bige.dev/about/BSDK

Instanciate

To create a new instance of BSDK you'll need an application setup on apim.bige.dev and a valid application Key, then you can init BSDK like this.

const APIM = new BSDK('your_app_key_from_apim.bige.dev', window.document.body)

Connect

If you want to made a private access to your app, you'll create an access group then attach the group to your application on APIM.

Also by default you can connect any by using this BSDK single line :

APIM.connect()

connect with UI

BSDK provide you an user interface for a better/faster integration. also you can connect any users by using BUI like this:

<div id="connectTest">
<script>
const APIM = new BSDK('your_app_key_from_apim.bige.dev', window.document.body)
APIM.UI.connectButton(
  document.querySelector('#connectTest'), 
  false, // Boolean set to true to display connect form in your interface
  {
    rounded: false, // true => sausage button
    loginLabel: "Login", // button label while not logged
    logoutLabel: "Logout", // button label when is logged
    dark: true, // false display a TEXT button wihtout background
    text: false,
    outlined: false, // for text button add outline colored
    ripple: true // add ripple for modern apps
  },
  {
    outlined: true
  }
);
</script>

APP access security setup

By configuring your app on APIM you can request access on any declared APIs then by using BSDK you can list your accesses rights like this :

APIM.setup.watch(setup => console.log(setup))

this is a sample response of application setup :

{
  "app": {
    "ID": 31,
    "groupID": 0,
    "label": "bsdk test",
    "privacy": "public"
  },
  "gates": {
    "STORAGE": {
      "ID": 6,
      "name": "Demo",
      "gate": "demo",
      "routes": [
        {
          "route": "/",
          "method": "get",
          "cost": 0,
          "scopes": [],
          "gate": "storage"
        }... // any apis routes
      ]
    }
  }
}

This application setup example define an authorized access right to gate Demo validated by the Demo api maintainer with a single GET route.

Once you've created your BSDK instance you can access this API endpoint documentation with a single line like this :

APIM.gates.demo['get:/].doc() // retrieve the Endpoint documentation

This feature is pretty cool to code faster and withtout switching to the documentation thats retrieve the OAS3 open api json documentation of this endpoint with query, params, request body and security attempts.

Note that any endpoint can request somes biges authorizations headers such as :

  • bige-api-key // need a valid user thats retrieve the user ID to allow APIs to make somes personnal stuffs
  • bige-app-key // need a valid application key only secured by app
  • bige-apim-key // not used with bsdk this key verify the auth access from API to API

The others security requested by any sertup is managed by APIM also you don't have anything more to do Also and with BSDK you don't have to be worry with any accesses key or authorizations setups on your front-end.

request an APIM API gate Endpoint :

To request any endpoint fromm BSDK you have to type somethig like this :

APIM.gates.demo['get:/'].call(null, null, null, null) // retrieve the gate Demo GET / endpoint

Any cal() params depends of the endpoint, also this is a basic explaination of the usage :

APIM.gates.demo['post:/foo/{id}'].call(
    {
        id:1 // the first param is the URL params
    }, 
    {
        foo: "bar" // the second is any query params ?hello=bar
    }, 
    {
        baz: "bar" // the thirth is the request body param (...)   
    }, 
    "application/json" // the forth is the content-type by default "application/json"
)

The forth param is relativetly important, the principal usecase is to access a from upload with multipart, So you'll simply send the attempting content type from the endpoint documentation and any attempting params format.

More informations :

BSDK provide you a lighweight UI and some others features, to learn more about BSDK please visit https://apim.bige.dev/documentation/BSDK (come soon...)