• Stars
    star
    234
  • Rank 171,630 (Top 4 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created almost 13 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Protocol Buffers for Node.JS

Node v6.x.x/7.x.x Now Supported

Many thanks to Mรกrio Freitas/imkira for his work. Thanks to work by Nikolai Vavilov/seishun, package uses `node-gyp``, a bundled protobuf lib and compiles on Windows. Currently maintained by Anton Antonov/syndbg.

Protobuf

This is a fork of http://code.google.com/p/protobuf-for-node/

Works/worked with NodeJS versions:

  • 0.8.x,
  • 0.10.x,
  • 4.x.x,
  • 5.x.x,
  • 6.x.x,
  • 7.x.x

To install:

# NPM version (may be slightly out-dated, but surely stable)
> npm install protobuf
# 0.8.x/0.10.x support version
> npm install https://github.com/chrisdew/protobuf.git#c4622aa2b954d43902a1444a5bf99957ac5d10c1
# 4.x.x/5.x.x support version
> npm install https://github.com/chrisdew/protobuf.git#399f22901dadecc8132aa86cc638c7a379bc61b2
# 6.x.x/7.x.x support version
> npm install https://github.com/chrisdew/protobuf.git#235983e4a991e2b25dfce26b4180a84edd2a925e

All the best,

Chris.

P.S. Breaking change in 0.8.6: uint64 and int64 are now read as Javascript Strings, rather than floating point numbers. They can still be set from Javascript Numbers (as well as from string).

P.P.S. Here's an example I did for #29 - most users won't need the complication of bytes fields.

buftest.proto

package com.chrisdew.buftest;

message BufTest {
  optional float num  = 1;
  optional bytes payload = 2;
}

buftest.js

var fs = require('fs');
var Schema = require('protobuf').Schema;

// "schema" contains all message types defined in buftest.proto|desc.
var schema = new Schema(fs.readFileSync('buftest.desc'));

// The "BufTest" message.
var BufTest = schema['com.chrisdew.buftest.BufTest'];

var ob = { num: 42 };
ob.payload = new Buffer("Hello World");

var proto = BufTest.serialize(ob);
console.log('proto.length:', proto.length);

var outOb = BufTest.parse(proto);
console.log('unserialised:', JSON.stringify(outOb));

var payload = new Buffer(outOb.payload);
console.log(payload);

Makefile: (second line begins with a TAB not spaces)

all:
    protoc --descriptor_set_out=buftest.desc --include_imports buftest.proto

output:

$ node buftest.js 
proto.length: 18
unserialised: {"num":42,"payload":{"0":72,"1":101,"2":108,"3":108,"4":111,"5":32,"6":87,"7":111,"8":114,"9":108,"10":100,"length":11}}
payload: <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>

Older instructions for use with the NodeJS 0.6.x series.

Prerequisites:

NodeJS v0.6.X npm

To install on Ubuntu and OSX:

The first steps are to build and install Google's protobuf library. Make sure you have the right version by running "protoc --version" after the install.

wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
tar -xzvf protobuf-2.4.1.tar.gz
cd protobuf-2.4.1/
./configure && make && sudo make install
cd

This installs the npm package.

npm install protobuf

For Ubuntu, update library paths.

sudo ldconfig

For OSX, you might need to add the path:

export DYLD_LIBRARY_PATH=/home/chris/node_modules/protobuf/build/Release:/usr/local/lib:$DYLD_LIBRARY_PATH

And test that it works... Run node, try

require('protobuf');

you should see:

{ Schema: [Function: Schema] }

As seen from the instructions above, this is my first attempt at packaging a slightly complex C++ module for NPM.

If you can help me simplify these instructions, please submit a patch.

Good luck,

Chris.

More Repositories

1

barricane-db

Simple, transparent, object persistence for NodeJS.
JavaScript
36
star
2

datejs

A NodeJS package for the datejs library.
JavaScript
30
star
3

deltaql

JavaScript
27
star
4

multicast-eventemitter

This package provides a LAN-wide shared event emitter.
JavaScript
19
star
5

jshilbert

This is a javascript programme for 2d->1d transforms from unit space to distance on a unit Hilbert curve.
JavaScript
15
star
6

node-syslog

Syslog functions wrapped for NodeJS.
C++
14
star
7

protobuf-wireshark

A fork of https://code.google.com/p/protobuf-wireshark/source/checkout
Python
14
star
8

NodeJS-UDP-Multicast

UDP-Multicast Sockets for NodeJS
C++
12
star
9

subsession

A jQuery plugin which allows a server to distinguish between tabs.
JavaScript
10
star
10

ha

(network interface level) High Availability using NodeJS
JavaScript
9
star
11

pl1-language-tools

An implementation PL/1 including a tree-based interpreter and virtual machine.
Python
6
star
12

jsmn

fork of https://bitbucket.org/zserge/jsmn
C
6
star
13

jsparsing

jsParsing is a parser framework in JavaScript
JavaScript
4
star
14

chinese_fountain

A Fountain Code based on Chinese Remainder Theorem.
JavaScript
4
star
15

pyparsing-autocomplete

Experimental branch of pyparsing - for the purpose of finding a clean way to add autocompletion functionality.
Python
3
star
16

dlestx

NodeJS stream decoder for DLE STX / DLE ETX framed data.
JavaScript
3
star
17

xv6

xv6
C
3
star
18

sctp

SCTP experiments
C
3
star
19

protostream

Emits protobuf messages from a stream, as they are encountered.
JavaScript
3
star
20

nodejs-ldjson

Line Delimited JSON for NodeJS
JavaScript
2
star
21

propagate

JavaScript
2
star
22

barricane-server

A NodeJS-based webserver which uses jQuery templates and KnockoutJS.
JavaScript
2
star
23

testb

another test
JavaScript
2
star
24

hospos

JavaScript
2
star
25

levenshtein-deltas

A levenshtein delta calculator.
JavaScript
2
star
26

tcpghost

A drop-in replacement for NodeJS's net.createServer which uses pcap to create a tee, clone or ghost connection.
JavaScript
2
star
27

eveshamwi

Evesham WI Website
1
star
28

tt

Command line time tracker written in Rust.
Rust
1
star
29

litif

Literate Interactive Fiction
JavaScript
1
star
30

test4

Python
1
star
31

modulo-fountain

A fountain code, based on modular arithmetic.
1
star
32

testa

a test
JavaScript
1
star
33

test9

JavaScript
1
star
34

deltaql-bootstrap

A bootstrap project for learning DeltaQL.
JavaScript
1
star
35

smallc

C
1
star
36

jsonspace

jsonspace
JavaScript
1
star
37

node-burrito

Wrap up expressions with a trace function while walking the AST with rice and beans on the side
JavaScript
1
star
38

cpu

homebrew CPU
1
star
39

firemole

1
star
40

test5

1
star
41

http_parser

A port of Ryan Dahl's http_parser to D
1
star
42

test

just a test repo
1
star
43

rxtx

A fork which hacks the build to make it compile on modern linux.
C
1
star
44

jifjaf

A CMS using NodeJS.
1
star
45

knockout-issue20

1
star
46

completion

An parser with auto-completion.
JavaScript
1
star
47

fountain

1
star
48

barricane-site

The barricane.com website.
1
star
49

haskell-sandbox

Just some askell experiments.
Haskell
1
star
50

anastom

A NoSQL Event-Sourced Database.
1
star
51

barricane-template

Yet another templating system.
1
star
52

chrisdew.github.com

Chris Dew's Site
JavaScript
1
star
53

postcodemapper

JavaScript
1
star
54

test3

test3
JavaScript
1
star
55

protobuf2jansson

A C library for converting protobuf serialised data into jansson JSON objects, using a .desc file provided at runtime.
C
1
star
56

barricane-wf-example

An example application using BarricaneWF
JavaScript
1
star
57

anastom-blog

An example (blog) application for the Anastom Event-Sourced Database.
1
star
58

barricane-wf

NodeJS Web Framework
1
star
59

test6

JavaScript
1
star
60

test2

just another test
Python
1
star
61

itemcollection

Shell
1
star
62

cbackend

C++
1
star
63

rsync

ubuntu rsync package patched with rw-devices
Shell
1
star
64

serastore

serum storage system
1
star
65

deltaql-site

WebApp to power deltaql.com
JavaScript
1
star