Allows for action validators and formatters to use both named methods and direction functions.
exports.cacheTest = { name: 'cacheTest', description: 'I will test the internal cache functions of the API', outputExample: {}, inputs: { key: { required: true, formatter: [ function(s){ return String(s); }, 'api.formatter.uniqueKeyName' // <----------- HERE }, value: { required: true, formatter: function(s){ return String(s); }, validator: function(s){ if(s.length < 3){ return '`value` should be at least 3 letters long'; } else{ return true; } } }, }, run: function(api, data, next){ // ... } };
And then you would define an initializer with your formatter:
'use strict'; module.exports = { initialize: function(api, next){ api.formatter = { uniqueKeyName: function(key){ return key + '-' + this.connection.id; } }; next(); }, };
There are so many ways to configure redis these days... handling the config options for all of them (sentinel? cluster?) is a pain... so lets just let the users configure things directly. It will be so much simpler!
config/redis.js
, you now define the 3 redis connections you need explicitly rather than passing config options around:var host = process.env.REDIS_HOST || '127.0.0.1'; var port = process.env.REDIS_PORT || 6379; var database = process.env.REDIS_DB || 0; exports['default'] = { redis: function(api){ var Redis = require('ioredis'); return { '_toExpand': false, // create the redis clients client: Redis.createClient(port, host), subscriber: Redis.createClient(port, host), tasks: Redis.createClient(port, host), }; } };
api.config.redis.channel
to api.config.general.channel
api.config.redis. rpcTimeout
to api.config.general. rpcTimeout
api.config.redis.client
rather than api.redis.client