miratronix / rapport Goto Github PK
View Code? Open in Web Editor NEWSimple Websocket wrapper that provides request/response functionality
License: MIT License
Simple Websocket wrapper that provides request/response functionality
License: MIT License
In order to add connection retry capabilities, rapport needs to add a default onOpen
and onClose
handler after executing plugins.
We need to add connection retry capabilities to the library, so that when the socket closes it reconnects automatically. This should support several retry strategies.
Add support for an automatic and configurable heartbeat. The heartbeat message content should be configurable, along with the interval at which they are sent.
When going through standard routes, we try the entire chain for a matching route before moving to the regex routes. We can improve this with a handledVerbs
property that we update when we add handlers (similar to the regex routes).
Thus, the routes object will look like this:
routes = { '/users': { chain: [], handledVerbs = {} } }
We should refactor for more consistency with express:
Add support for adding multiple router wide handlers in one use call. For example:
router.use((req, res) => {}, (req, res) => {})
We should refactor instances of "global handler" with "middleware", to better match the express terminology.
Error handlers should be called "Error handling middleware functions".
We should add support for the following router syntax:
router.get(['/users', '/users/:id'], (req, res) => {})
Rapport should not make assumptions about what users want to do with string messages. Scrap the utility for parsing and stringify and move the logic to the default stringify Rapport option.
If a message is omitted when closing a socket, the client receiving the close dies. This is because onClose
will call util.parse('','');
, and since ''
is falsey, that does not count as a default value.
The default value check in 'util.parseshould be changed to
typeof defaultValue !== 'undefined'`
When respond to a request with an error, the error object is not stringified properly. The following test fails:
it('Wraps an error object and sends it', () => {
wrappedSocket.respondWithError('some ID', new Error('error message'));
mockSocket.messagesSent.should.equal(1);
const message = JSON.parse(mockSocket.lastSentMessage);
message.should.have.a.property('responseId').that.equals('some ID');
message.should.have.a.property('error').that.is.an('object');
message.error.should.have.a.property('message').that.equals('error message');
});
Add support for configuring multiple ws creation options.
For example, ws
sockets can be created with new ws(url, protocols, options)
.
Right now, sockets can only be created with 1 option parameter, effectively removing the ability to set anything but the protocols
in the above example.
We should add a .use(type, ...handlers)
function to the wrapped socket, which allows for a middleware chain based on the type
property in a message. Middleware should include a (msg, ws, next)
parameters, similar to express.
We should add header support to http style request/responses, Similar to the express .set
methods.
Add support for wildcard routing. In express you can do routing like:
`router.get('/users*', () => {});
When sending a string, array, or other non-object message to the server in JSON form, such as ""hello""
the default parser reads it into "hello"
. The onMessage
handler then fails to attach isRequest
, because the message is a string. The same is true for arrays.
We may need to add an object check in the default parse, so it throws if the parsed value is not an object after parsing.
If a string message is sent via the library, the default JSON stringify converts it to a double quoted string.
For example, Rapport.create(WebSocket).send('hello')
will send ""hello""
to the peer.
We need to add a string check to the default stringify function, to prevent doubling up encoding on strings.
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.