question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How does this behave with routers?

See original GitHub issue

Hey there, awesome library that removes a lot of hassle, really!

I have this particular use case in which I am releasing a library which expose a Express router, so here is the following use case:

var linkedDataProvider = require("./ldp")
var express = require("express")
var app = express();
app.use('/test', ldp({patch: true}));

Now, the implementation of ldp is as following:

module.exports = function(opts) {
  var router = new express.Router();
  [...]
  router.post("/", postOrPatch);
  router.delete("/", deleteObj);
  [...]
  return router;
}

Now, if I want to include

router.ws(''/", realTime);

How can make this happen?

My ideas are the following

  • I require(‘express-ws’)(router) ?
  • I have express-ws outside my library, so if you need you can set extra property
  • I have to have another function for creating ldp routes like ldp(route)(app)

Thanks a lot for your time

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
HenningMcommented, Jan 30, 2015

Hi,

First of all: I’m flattered that you find this library useful.

I also agree that the feature described here would be a very nice addition, so I’ll have a look at it ASAP. Unfortunately it’s not entirely straightforward to implement support for routers since they don’t have any information on where they are mounted in the application. This means that we don’t know which path to give the WebSocketServer when we run router.ws('/socket', handler). The router could be mounted anywhere in the application.

I will try to come up with a (not too hacky) solution here though, and I’ll keep you updated.

0reactions
nicolacommented, May 1, 2016

This is awesome, thanks! @joepie91 , @HenningM

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is a Router and How Does It Work? - Lifewire
A router is the first line of security from intrusion into a network. Enabling the highest level of security on the router turns...
Read more >
What Is A Router And How Does It Work? Latest Blog Posts
A router is responsible for organising communication between computer networks. A router takes data packets from devices and directs them to the ...
Read more >
How Does a Router Work? - Cisco
Routers connect computers and other devices to the Internet. A router acts as a dispatcher, choosing the best route for your information to...
Read more >
How does a router behave when some of the fragments of a ...
Routers typically do not care about fragmentation. They pass things on exactly ... As such, the router will be unaware of missing fragments....
Read more >
Do routers act like switches when devices are connected to it ...
Thus, the concept of a router or forwarder is needed. Hosts in the same network can reach each other directly, if they are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found