Socket
Socket
Sign inDemoInstall

couch-daemon-bridge

Package Overview
Dependencies
9
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.3.0

6

index.js

@@ -28,2 +28,3 @@ /* couch-daemon-bridge

var cmd = ['log', typeof msg === 'string' ? msg : JSON.stringify(msg)];
if (level) {

@@ -43,3 +44,3 @@ cmd = cmd.concat({ level: level });

if (parts.length !== 2) {
if (parts.length !== 1 && parts.length !== 2) {
return callback({ error: 'malformed config key', reason: 'Keys must be of the form "section.key"' });

@@ -55,2 +56,5 @@ }

stdin.once('data', function(data) {
if (parts.length === 1) {
data = JSON.parse(data);
}
callback(null, data);

@@ -57,0 +61,0 @@ });

2

package.json
{
"name": "couch-daemon-bridge",
"version": "1.2.2",
"version": "1.3.0",
"description": "Use CouchDBs os_daemons with node.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,8 +19,27 @@ # couch-daemon-bridge

// Request configuration
daemon.get('httpd', function(data) {
// data is now an object holding the whole httpd section
});
daemon.get('httpd.bind_address', function(data) {
// data is now a string holding the value
});
```
### Environment Variables
Every configuration can be overridden via environment variable:
```shell
export HTTPD_BIND_ADDRESS="93.184.216.119"
```
```js
var daemon = require('couch-daemon-bridge')(process.stdin, process.stdout, function() {
process.exit(0);
});
// Request configuration
daemon.get('httpd.bind_address', function(data) {
// data is now a string holding the value of HTTPD_BIND_ADDRESS if present
});
```
## Contributing

@@ -27,0 +46,0 @@ 1. Write tests with [tap](https://github.com/isaacs/node-tap)

@@ -5,2 +5,61 @@ var es = require('event-stream');

test('get whole configuration section', function(t) {
var config = {
my_key: 'my_value'
};
var stdin = es.readArray([
JSON.stringify(config)
])
.pipe(es.stringify());
var stdout = es.writeArray(function(err, data) {
var message;
message = JSON.stringify(['register', 'my_section']) + '\n';
t.equal(data[0], message, 'should have registered for "my_section"');
message = JSON.stringify(['get', 'my_section']) + '\n';
t.equal(data[1], message, 'should have requested "my_section" config');
});
var d = daemon(stdin, stdout, function() {
t.end();
});
d.get('my_section', function(err, res) {
t.deepEqual(res, config, 'correct object returned');
});
});
test('get whole configuration section from object', function(t) {
var config = {
my_key: 'my_value'
};
var stdin = es.readArray([
JSON.stringify(config)
])
.pipe(es.stringify());
var stdout = es.writeArray(function(err, data) {
var message;
message = JSON.stringify(['register', 'my_section']) + '\n';
t.equal(data[0], message, 'should have registered for "my_section"');
message = JSON.stringify(['get', 'my_section']) + '\n';
t.equal(data[1], message, 'should have requested "my_section" config');
});
var d = daemon(stdin, stdout, function() {
t.end();
});
d.get({ myconfig: 'my_section' }, function(err, res) {
t.deepEqual(res.myconfig, config, 'correct object returned');
});
});
test('single configuration key', function(t) {

@@ -7,0 +66,0 @@ var stdin = es.readArray([

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc