force-mapper
v1.0.0
Published
JSForce connection mapper middleware
Downloads
4
Readme
force-mapper
[![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url]
Node.js jsforce mapping module
Installation
npm install force-mapper
API
var ForceMapper = require('force-mapper')
// See below for detailed opts configuration
var forceMapper = ForceMapper(opts);
var myTokenData = {
access_token: '123',
instance_url: 'salesforce.provided.url'
};
var conn = forceMapper.get('123', myTokenData); // Standard jsForce.Connection object
var internalCache = forceMapper.getCache(); // Standard lru-cache object
Middleware
Alternatively, you can use ForceMapper.middleware if you wish to attach the connection onto an Express req
object
var ForceMapper = require('force-mapper')
// See below for detailed opts configuration
var opts = {
middleware: {
tokenDataPath: 'session.salesforce.accessToken',
connectionPath: 'sfConn',
keyPath: 'user.email'
}
}
var forceMapper = ForceMapper(opts);
Options
cache
opts.cache
is an exposing of lru-cache options
middleware
var opts = {
middleware: {
tokenDataPath: 'path-to-salesforce-token-object',
connectionPath: 'path-to-store-jsforce-connection',
keyPath: 'path-to-map-key'
}
}