graftjs / graft-http Goto Github PK
View Code? Open in Web Editor NEWGraft HTTP/REST integration
License: MIT License
Graft HTTP/REST integration
License: MIT License
this is what i currently use in aether board
i'm pretty sure that can be made cleaner, so something like :
var graft = require('graft');
var server = require('graft-http').server(3000);
var socket = require('graft-ws').server();
server.pipe(socket);
socket.pipe(graft);
I wanted to start a new issue thread for figuring out how we will serialize requests and responses into graft messages.
I see 3 problems we need to solve:
Below is an ongoing draft of what these message blocks would look like:
// request
{
httpVersion:
method:
url:
host:
hostname:
path:
protocol:
port:
query:
params:
body: req
res: graft.ReadChannel()
}
// response
{
statusCode:
headers:
body: // string, buffer, stream
}
I think 1 and 2 are already solved, we just need to decide on the message properties. For 3, I don't know how to best handle this. We would have a request stream, response stream, but also a return channel? Is there a way to merge these somehow?
@GraftJS/graft-http-committers
this is pretty much just a wrapper around http.createServer, that has a graft instance inside of it that it uses to resolve the request.
it will map the response into a returnChannel, and pass the message along.
It should allow you to use all the other stream-oriented http tools that exist, and stay the fsck out of everyone's way as much as possible.
bonus points: be able to pipe messages through a graft http request service, that has been piped into a locally running graft http server =P you know. for tests...
So while thinking about the idea of authenticated streams using passport, and it occured to me that you just needed a standard way to represent an http request as a graft message. turn those messages into http requests , and turn the responses back into graft messages.
so you could mount an http server or express stack as a stream function. that would allow you to mount passport on it, and do some other pretty nifty things.
maybe even something like this for graft : http://hueniverse.com/2015/06/02/introducing-chairo-a-hapi-js-microservices-plugin/
same thing as the http server, but probably a thin wrapper around mikael's request or substack's hyperquest.
bonus points: being able to pipe messages that get turned into http requests that can be piped into an graftified http server instance (you know, for tests =) )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.