Created
December 3, 2015 17:34
-
-
Save domachine/c757b396d5e69da7d221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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