{"id":22486761,"url":"https://github.com/GraftJS/graft","last_synced_at":"2025-08-02T19:33:01.244Z","repository":{"id":57253028,"uuid":"21430740","full_name":"GraftJS/graft","owner":"GraftJS","description":"full-stack javascript through microservices","archived":false,"fork":false,"pushed_at":"2018-12-16T15:37:19.000Z","size":123,"stargazers_count":227,"open_issues_count":8,"forks_count":15,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-11-28T21:17:58.592Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://graft.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GraftJS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-02T16:07:20.000Z","updated_at":"2024-02-28T18:57:49.000Z","dependencies_parsed_at":"2022-08-31T22:20:50.743Z","dependency_job_id":null,"html_url":"https://github.com/GraftJS/graft","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraftJS%2Fgraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraftJS%2Fgraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraftJS%2Fgraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraftJS%2Fgraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GraftJS","download_url":"https://codeload.github.com/GraftJS/graft/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228500199,"owners_count":17930007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-06T17:15:20.561Z","updated_at":"2024-12-06T17:16:09.266Z","avatar_url":"https://github.com/GraftJS.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Service Toolkits"],"sub_categories":["Node.js"],"readme":"__Warning: This library is incomplete and unmaintained. Check out [UpringJS](https://github.com/upringjs/upring) by one of the original founders if you want something similar.__\n\n![Graft](https://rawgit.com/GraftJS/graft.io/master/static/images/graft_logo.svg)\n\nThe [Graft project](http://graft.io) explores what the web could become, if we extended microservice architectures into the client.\n\n  * \u003ca href=\"#motivation\"\u003eMotivation\u003c/a\u003e\n  * \u003ca href=\"#api\"\u003eAPI\u003c/a\u003e\n  * \u003ca href=\"#libchan\"\u003eAbout LibChan\u003c/a\u003e\n  * \u003ca href=\"#contributors\"\u003eContributors\u003c/a\u003e\n  * \u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\n\n[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/GraftJS/graft?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n__Interested in Graft and jsChan?__ Watch @mcollina presentation at [NodeConf.eu 2014](http://nodeconf.eu/), [\"Full Stack Through Microservices\"](https://github.com/mcollina/nodeconfeu-2014-full-stack-through-microservices)\n\nMotivation\n----------\n\nWhen you graft something, it involves joining together parts to create a new whole.\nOne that is hopefully more adaptable, resilient and ultimately interesting.\n\n\u003e \"Instead of pretending everything is a local function even over the network ..., what if we did it the other way around?\n\u003e Pretend your components are communicating over a network even when they aren't?\"\n\u003e   -- Docker's [Solomon Hykes](http://github.com/shykes) on [LibChan](http://github.com/docker/libchan) - [[link]](https://news.ycombinator.com/item?id=7874317)\n\n### [Explore our concepts and influences](http://wayfinder.co/pathways/5365c71219e552110093ba31/graft-full-stack-node-js-through-microservices)\n\n---\n\n#### Our Projects\n\n* [__graft__](https://github.com/GraftJS/graft): the library that ties everything together.\n* [__jschan__](https://github.com/GraftJS/jschan): our 'standard carrier'. A port of [libchan](https://github.com/Docker/libchan).\n* [__aetherboard__](https://github.com/AetherBoard/aetherboard): our 'hello world' demo. A collaborative whiteboard.\n\n#### Our Process\n\n* discover how to connect tools through microservices.\n* explore the tools that are already available.\n* adapt those that could be integrated.\n* innovate to build those that don't exist yet.\n\n#### Our Principles\n\n* favor small tools that serve only one purpose, but do so well.\n* eschew state, because it only leads to trouble.\n* focus on javascript, because it is universal.\n* evaluate and document, not prescribe.\n* educate.\n\n#### Our Goals\n\n* be the premier javascript implementation of libchan.\n* be completely supported for node.js as soon as possible.\n* use Node.JS streams to replicate the semantics of Go Channels.\n* be functional and usable on the browser as we test the waters.\n* use virtual stream objects to provide an api similar to [Gulp](http://gulpjs.org).\n* attempt control flow abstractions similar to [HighlandJS](http://highlandjs.org).\n* experiment, document and learn.\n\n---\n\n\u003ca name=\"api\"\u003e\u003c/a\u003e\n\nAPI\n---\n\n  * \u003ca href=\"#graft\"\u003e\u003ccode\u003e\u003cb\u003egraft()\u003cb\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#graft.ReadChannel\"\u003e\u003ccode\u003egraft.\u003cb\u003eReadChannel()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#graft.WriteChanel\"\u003e\u003ccode\u003egraft.\u003cb\u003eWriteChanel()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#graft.branch\"\u003e\u003ccode\u003egraft.\u003cb\u003ebranch()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#graft.where\"\u003e\u003ccode\u003egraft.\u003cb\u003ewhere()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#request\"\u003eRequest Interface\u003c/a\u003e\n  * \u003ca href=\"#spdyclient\"\u003e\u003ccode\u003espdy.\u003cb\u003eclient()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#spdyserver\"\u003e\u003ccode\u003espdy.\u003cb\u003eserver()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#wsclient\"\u003e\u003ccode\u003ews.\u003cb\u003eclient()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n  * \u003ca href=\"#wsserver\"\u003e\u003ccode\u003ews.\u003cb\u003eserver()\u003c/b\u003e\u003c/code\u003e\u003c/a\u003e\n\n-------------------------------------------------------\n\n\u003ca name=\"graft\"\u003e\u003c/a\u003e\n### graft()\n\nThe main object of this library. A `Graft` instance is a\n[`Transform`](http://nodejs.org/api/stream.html#stream_class_stream_transform)\nstream with `objectMode: true`.\nThe objects on the _output_ of a `Graft` instance are\n[Request](#request)s. On the input side, you can write just _normal JS\nobjects_, and everything else you can [write to a jsChan\nchannel](https://github.com/GraftJS/jschan#what-can-we-write-as-a-message).\nThese objects will be automatically wrapped up in a [Request](#request).\n\nInternally, each `Graft` instance is backed by\n[jschan.memorySession()`](https://github.com/GraftJS/jschan#memorySession).\n\nIn order to process the requests, you can just:\n\n```js\nvar graft = require('graft')();\nvar through = require('through2');\n\ngraft.pipe(through.obj(function(msg, enc, cb) {\n  console.log(msg); // prints { hello: 'world' }\n  // process your request\n  cb();\n}));\n\ngraft.write({ hello: 'world' });\n\n```\n\n\u003ca name=\"graft.ReadChannel\"\u003e\u003c/a\u003e\n#### graft.ReadChannel()\n\nReturns a nested read channel, this channel will wait for data from the\nother party.\n\n\u003ca name=\"graft.WriteChannel\"\u003e\u003c/a\u003e\n#### graft.WriteChannel()\n\nReturns a nested write channel, this channel will buffer data up until\nis received by the other party.\n\n\u003ca name=\"graft.branch\"\u003e\u003c/a\u003e\n#### graft.branch(function(req), stream)\n\nPasses the request to the first argument, and if that returns a _truthy_\nvalue, it calls `write(req)` on the associated stream.\nIt respect backpressure.\n\n\u003ca name=\"graft.where\"\u003e\u003c/a\u003e\n#### graft.where(obj, stream)\n\nShortcut for the most common usage of `graft.branch()`, it allows to\nrewrite:\n\n```js\ngraft.branch(function(msg) {\n  return msg.hello === 'world'\n}, stream)\n```\n\ninto:\n\n```js\ngraft.where({ hello: 'world' }, stream)\n```\n\n-------------------------------------------------------\n\n\u003ca name=\"request\"\u003e\u003c/a\u003e\n### Request Interface\n\nEach __Graft__ request is the _first message sent on a top-level channel_, and it is composed of:\n\n* all the properties of the message\n* __`_channel`__, the associated channel\n* __`_session`__, the associated session\n\nEach request will have its own channel, but the session is generic for\nevery client.\n\nThe `_channel` and `_session` properties will not be enumerable.\n\n-------------------------------------------------------\n\n\u003ca name=\"spdyclient\"\u003e\u003c/a\u003e\n### spdy.client()\n\nCreates a new spdy client to pipe to:\n\n```js\nvar graft = require('graft')();\nvar spdy = require('graft/spdy');\n\ngraft.pipe(spdy.client({ port: 12345 }));\n\ngraft.write({ hello: 'world' });\n```\n\n-------------------------------------------------------\n\n\u003ca name=\"spdyserver\"\u003e\u003c/a\u003e\n### spdy.server()\n\nCreates a new spdy server that you can pipe to a graft instance:\n\n```js\nvar graft = require('graft')();\nvar spdy = require('graft/spdy');\nvar through = require('through2');\n\nspdy\n  .server({ port: 12345 })\n  .pipe(graft)\n  .pipe(through.obj(function(msg, enc, cb) {\n    console.log(msg); // prints { hello: 'world' }\n    // process your request\n    cb();\n  }));\n```\n\n-------------------------------------------------------\n\n\u003ca name=\"wsclient\"\u003e\u003c/a\u003e\n### ws.client()\n\nCreates a new ws client to pipe to:\n\n```js\nvar graft = require('graft')();\nvar ws = require('graft/ws');\n\ngraft.pipe(ws.client({ port: 12345 }));\n\ngraft.write({ hello: 'world' });\n```\n\nIt works even from a Browser, using\n[WebPack](http://npm.im/webpack) or [Browserify](http://npm.im/browserify).\n\n-------------------------------------------------------\n\n\u003ca name=\"wsserver\"\u003e\u003c/a\u003e\n### ws.server()\n\nCreates a new ws server that you can pipe to a graft instance:\n\n```js\nvar graft = require('graft')();\nvar ws = require('graft/ws');\nvar through = require('through2');\n\nws\n  .server({ port: 12345 })\n  .pipe(graft)\n  .pipe(through.obj(function(msg, enc, cb) {\n    console.log(msg); // prints { hello: 'world' }\n    // process your request\n    cb();\n  }));\n```\n\nYou can even pass an existing http server that will be hooked up, like\nso:\n\n```js\nvar graft   = require('graft');\nvar ws      = require('graft/ws');\nvar http    = require('http');\nvar server  = http.createServer();\n\nws\n  .server({ server: server })\n  .pipe(graft())\n```\n\n\u003ca name=\"libchan\"\u003e\u003c/a\u003e\nAbout LibChan\n-------------\n\nLibchan is the connective tissue to all our endeavours. It is a microservices library announced by the Docker project,\nand it is going to form the basis of all of the tools they build in the future.\n\nIt's most unique characteristic is that it replicates the semantics of go channels across network connections, while allowing for nested channels to be transferred in messages. This would let you to do things like attach a reference to a remote file on an HTTP response, that could be opened on the remote end for reading or writing.\n\nThe protocol uses SPDY as it's default transport with MSGPACK as it's default serialization format. Both are able to be switched out, with http1+websockets and protobuf fallbacks planned.\n\nWhile the RequestResponse pattern is the primary focus, Asynchronous Message Passing is still possible, due to the low level nature of the protocol.\n\n\u003ca name=\"contributors\"\u003e\u003c/a\u003e\nContributors\n------------\n\n* [Adrian Rossouw](http://github.com/Vertice) - Co-Founder\n* [Peter Elgers](https://github.com/pelger) - Co-Founder\n* [Matteo Collina](https://github.com/mcollina) - Co-Founder\n\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\nLicense\n-------\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraftJS%2Fgraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGraftJS%2Fgraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraftJS%2Fgraft/lists"}