0.1.0 • Published 2 years ago

node-blox-sdk v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

node-blox-sdk

Blox Node.js SDK - includes libraries for SHIELD services and Function Blox Configurations

SDK Usage

  1. To write a function,
npm install node-blox-sdk -s

Run Handler / Function using run method by importing functions sdk from node-blox-sdk.

import { functions } from "node-blox-sdk";

export blox_name = (req, res) => {

// business logic
}

functions.run(blox_name)
  1. SHIELD
npm install node-blox-sdk

Before using shield, app need to be initialized.

Initialze the application using internals SDK

import { internals } from "node-blox-sdk";

internals.initialize({
		clientId:     process.env.CLIENT_ID,
		clientSecret: process.env.CLIENT_SECRET,
	})

Using the methods from shield sdk

import { shield } from "node-blox-sdk";

const SheildExampleHandler = async (req, res, next) => {
  try {
  
    // Get user details using shield
    const userDetails = await shield.getUser(req);

    // Get user uid using shield
    const userUID = await shield.getUID(req);

  } catch (error) {
    // handle the error
  }
};

Run SheildExampleHandler using run method from funciton sdk.

import { functions } from "node-blox-sdk";

functions.run(SheildExampleHandler)

To run a function, There is 2 option

  1. Using CLI
blox start blox_name

to start an individual blox.

or

blox start

to start them all.

  1. Assigning a port manually using flags.
cd ./examples/functions-example/
node index.js --port=3000 

the above command will run function in port 3000

go to github.com/AppBlox/node-blox-sdk/tree/main/examples/shield-example to see more example.

Read Docs for advanced tooling

0.1.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago