Node

REST API

See root documentation of API References.

Helper Library

Can make a db.js and can access common functions.

db.js
var request = require("request");
var accessKey = process.env.ACCESS_KEY;
var endpoint = "https://memory.backbench.io";

module.exports = {
    "bbMemSet": function(key, value, cb){
       request.post({
            url: "https://memory.backbench.io",
            body: {
            "cmd": "bb:mem:set",
            "auth": {
                "benchId": "addressbookapp",
                "userId": "peeyushsrj",
                "accessKey": accessKey
              },
              "args": {
                "key": key,
                "value": value
              }
            },
            json: true
        }, function (error, response, body) {
            if (error) {
                cb(error);
            } else{
                cb(undefined, body);
            }
        }); 
    }, 
    "bbMemGet": function(key, cb){
       request.post({
            url: "https://memory.backbench.io",
            body: {
            "cmd": "bb:mem:get",
            "auth": {
                "benchId": "addressbookapp",
                "userId": "peeyushsrj",
                "accessKey": accessKey
              },
              "args": {
                "key": key
              }
            },
            json: true
        }, function (error, response, body) {
            if (error) {
                cb(error);
            } else{
                cb(undefined, body.reply);
            }
        }); 
    },
    "bbLog": function(message, cb){
       request.post({
            url: "https://memory.backbench.io",
            body: {
            "cmd": "bb:log",
            "auth": {
                "benchId": "addressbookapp",
                "userId": "peeyushsrj",
                "accessKey": accessKey
              },
              "args": {
                "message": message
              }
            },
            json: true
        }, function (error, response, body) {
            if (error) {
                cb(error);
            } else{
                cb(undefined, body.reply);
            }
        }); 
    }
};

SDK

Available publicaly on https://www.npmjs.com/package/backbench-node-sdk.

NOTE: For local development you need to copy ACCESS_KEY environment variable from platform and make it as local environment variable with same key. Also need to require backbench-node-sdk for local.

Getting memory

Setting memory

Deleting memory

Logging

Example

File Upload

You can upload your file with a regular enctype='multipart/form-datain using POST method your HTML form.

The file you have uploaded will be in base64. That you can either convert to text or store it in database.

Here's the response body printed at backend.

And this is the code for printing it.

Note: Currently supports only single file upload.

Last updated