transcend-backend-helpers
General helper functions for backend code using Transcend
Installation
npm install transcend-backend-helpers
Setup
In order to use any functions that connect to the Transcend API, you must first call setupEnvironment which will set a number of parameters needed to make authenticated requests, as well as establish secure values for your backend system. The environment will be preconfigured with default values if no .env file is found in your application directory. Simple copy .env-default into your-repo/.env and change the values to work with your app.
The file .env-default-all includes all of the parameters that will be initialized in setupEnvironment().
Use
const tbh = require("transcend-backend-helpers");
// Configure the default environment variables (will load from .env file if exists)
tbh.setupEnvironment()
// Access token for a specific user in your app
const transcendToken = "130912basdn2301nldfi219103";
// userId of a user in your app
const transcendUserId = 1;
// Get the data of a user in an app
const userData = tbh.requestDataFromToken(transcendToken)
// Get the userIds for the friends of a user in your app
const friendIds = tbh.requestFriendsFromToken(transcendToken)
// Using your admin token, get the data associated with a userId
const friendsData = friendIds.map((friendId) => tbh.requestDataFromId(friendId));
// Get the associated user token from a userId
const friendsTokens = friendIds.map((friendId) => tbh.requestTokenFromId(friendId));