Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
redis-jsonify
Advanced tools
Save JSON representation of objects to redis when using node_redis
I basically always save JSON objects to redis. As far as I can tell there isn't a way to make @mranney's node_redis implicitly convert objects and arrays to JSON before they are sent off to redis. So I would always to have to wrap my set and get calls with JSON.parse/stringify nonsense.
This module exports a function which when passed a RedisClient instance will proxy the send_command method and convert anything that is not a Buffer to and from JSON. I considered modifying the RedisClient prototype automatically when this module is included in your project, but decided against it because you may not want this behavior on all of your redis clients.
This module is compatible with most versions of node_redis from 0.6.7 to 2.8.0 except 2.4.2 and 2.3.1.
with npm...
npm install redis-jsonify
or with git...
git clone git://github.com/wankdanker/node-redis-jsonify.git
var redis = require('redis')
, jsonify = require('redis-jsonify')
, client = jsonify(redis.createClient())
;
client.set('asdf', { foo : "bar" }, function (err, result) {
client.get('asdf', function (err, result) {
console.log(result);
// should be { foo : "bar" } and not [Object object]
client.quit(function () { });
});
});
I'm not a huge redis buff yet, so there may be certain commands for which this
is not a good idea. One example would be the list
command. The value returned
by the list
command is not JSON. To disable the JSON processing for certain
commands there is a command blacklist array exported by the module. It currently
only contains the list
command. If you know of other commands that should be
blacklisted by default or there should be special processing, let me know and
I'll add them. Pull requests welcome also.
var jsonify = require('redis-jsonify');
//add somecommand to the blacklist
jsonify.blacklist.push('somecommand');
//dump the blacklist to console
console.log(jsonify.blacklist);
Copyright (c) 2012 Daniel L. VerWeire
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Save JSON representation of objects to redis when using node_redis
The npm package redis-jsonify receives a total of 189 weekly downloads. As such, redis-jsonify popularity was classified as not popular.
We found that redis-jsonify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.