Skip to content

Instantly share code, notes, and snippets.

@domachine
Created December 3, 2015 17:34
Show Gist options
  • Save domachine/c757b396d5e69da7d221 to your computer and use it in GitHub Desktop.
Save domachine/c757b396d5e69da7d221 to your computer and use it in GitHub Desktop.
'use strict';
var net = require('net');
var multilevel = require('multilevel');
var level = require('level');
var db = level('db');
var server = net.createServer(con => {
con.pipe(multilevel.server(db, {
access() {
throw new Error('unauthorized');
}
})).pipe(con);
});
server.listen(3000, () => {
let db = multilevel.client();
let con = net.connect(3000);
con.pipe(db.createRpcStream()).pipe(con);
db.createReadStream()
.on('error', err => console.log('Error!', err.message))
.on('data', d => console.log('Data', d))
.on('end', () => console.log('End'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment