0.5.1 • Published 2 years ago

bitloops v0.5.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Bitloops

bitloops

NodeJS library for the Bitloops

Usage

Installing

Using npm:

$ npm install bitloops

Using yarn:

$ yarn add bitloops

TypeScript Frontend usage Example

import Bitloops, { AuthTypes, BitloopsUser, getAuth } from 'bitloops';

// You will get this from your Console in your Workflow information
const bitloopsConfig = {
	apiKey: "kgyst344ktst43kyygk4tkt4s",
	server: "bitloops.net",
	environmentId: "3c42a5ef-fe21-4b50-8128-8596ea47da93",
	workspaceId: "4f7a0fc5-fe2f-450a-b246-11a0873e91f0",
	messagingSenderId: "742387243782",
  auth: {
    authenticationType: AuthTypes.User,
    providerId: 'myProviderId', // You create this in the Bitloops Console
    clientId: 'myWebAppId', // You create this in the Bitloops Console
  }
}

const bitloops = Bitloops.initialize(bitloopsConfig);

bitloops.auth.authenticateWithUsername('username', 'email', 'password');
bitloops.auth.authenticateWithEmail('email', 'password');
bitloops.auth.authenticateWithEmailLink('email');
bitloops.auth.authenticateWithEmailLinkVerification('link');
bitloops.auth.forgotPassword('email', 'username');
bitloops.auth.forgotPassword('email');
bitloops.auth.forgotPasswordLink('link');
bitloops.auth.forgotPasswordLink('link', 'new-password');

bitloops.auth.authenticateWithGoogle();
bitloops.auth.registerWithGoogle();
bitloops.auth.addGoogle();
bitloops.auth.authenticateWithGitHub();
bitloops.auth.registerWithGitHub();
bitloops.auth.addGitHub();
bitloops.auth.authenticateWithTwitter();
bitloops.auth.registerWithTwitter();
bitloops.auth.addTwitter();
bitloops.auth.sendVerificationCode(phone);
bitloops.auth.verifyPhoneCode(phone, code);

bitloops.auth.getUser();
bitloops.auth.clear();

bitloops.auth.onAuthStateChanged((user: BitloopsUser) => {
  if (user) {
    // Do stuff when authenticated
  } else {
    // Do stuff if authentication is cleared
  }
});

...

const userInfo = await bitloops.request('db7a654a-1e2c-4f9c-b2d0-8ff2e2d6cbfe', '70e3084f-9056-4905-ac45-a5b65c926b1b');
const productInfo = await bitloops.request('64f264ad-76b1-4ba1-975c-c7b9795e55ce', '70e3084f-9056-4905-ac45-a5b65c926b1b', { productId: '7829' });
bitloops.publish('page-visited-event', { page: 'landing-page'});

PRO TIP: The second argument passed in the product.getProductInfo request and in the page-visited-event publish message containing the data of the request/publish message is using a shortcut notation which you can use if the only arguments other than the requestId or the messageId are the payload parameters. The full form is the following:

bitloops.publish('page-visited-event', { payload: { page: 'landing-page' } });

The above is equivalent to:

bitloops.p('page-visited-event', { page: 'landing-page' });

This means that if you need to pass more settings to the request / publish message then you need to explicitly define the payload argument.

Testing Example

To ask your workflows to return mocked values based on your test scenarios you can pass the testScenarioId along with your request.

const productInfo = await bitloops.request('product.getProductInfo', {
  payload: { productId: '7829' },
  testScenarioId: 'Test-Scenario-1',
});

Subscriptions

const callback = (data: any) => {
  console.log('Received', data);
};
bitloops.subscribe('ride-requested', callback);

Questions?

Please post your questions on Stack Overflow making sure you use the Bitloops tag and someone from the Bitloops team or the community will make sure to help you.

Alternatively feel free to submit an Issue on GitHub.

0.5.0

2 years ago

0.5.1

2 years ago

0.4.1

2 years ago

0.1.10

2 years ago

0.3.0

2 years ago

0.1.9

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.4.0

2 years ago

0.2.2

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.11

3 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago