Server API Reference

How to Use Server Side Functions

Preparing to use BrixxServerApi

Install from npm. This will give your project access to the BrixxServerApi.

npm i @brixxbox/brixx-server-api

Reference the Class BrixxServerApi from your function source.

const BrixxServerApi = require('@brixxbox/brixx-server-api');

Create an instance from BrixxServerApi to access the avialable methods.

//Note: the constructor will always get the 2. parameter from 
//the functions call as parameter. This parameter expects the brixxboxMeta 
//as part of the body content (req.body.brixxboxMeta) 
const brixxServerApi = new BrixxServerApi(req);

Now the different methods from brixxServerApi can be called.

Example


const BrixxServerApi = require('@brixxbox/brixx-server-api');

module.exports = async function (context, req) {
    const brixxServerApi = new BrixxServerApi(req);
    currencyRate = await brixxServerApi.businessBrixx({
        functionName:"CurrencyConverter",
        methodName: "Convert",
        fromCurrencySymbol: "EUR",
        toCurrencySymbol: "USD"
    });

    //result back to caller (if needed)
    context.res = {
        status: 200,
        body: { 
            responseMessage: 'Rate EUR/USD: ' + currencyRate,
            currencyRate: currencyRate
        }
    };
}

Server Side Api Function List

To invoke a server function from the a brixxApi client please check serverFunction

Last updated