npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

devrouter

v1.2.1

Published

Easy router for developing http services

Downloads

15

Readme

Devrouter

Devrouter is a simple tool for managing lots of local webservers for development. Do you ever get the problem where you have one project running on port 8000, one on 8080, one on 3000, etc and you can't keep track of them any more? That's the problem devrouter is designed to solve.

Instead of typing, node myserver.js, you can type devroute node myserver.js. Devrouter will find a free port and set it to the PORT environment variable so your server can pick it up. Meanwhile, it also passes that port and the name of the current directory to the Devrouter service's HTTP proxy. So you can now visit it at, for example, http://myserver.dev.

Now all your local development services can be referenced by nice names instead of arbitrary ports!

Setup

Devrouter is on npm, so install it with npm install -g devrouter

Devrouter has two commands. The service is devrouter and the utility is devroute <-- note the lack of an r at the end.

You run the Devrouter service with devrouter, but you will probably need to sudo devrouter so that it can run as port 80. There are other, more secure ways of doing this, but they are all a bit annoying. We drop privileges after listening, so it's not so bad, but you may want to have a look through the code to make sure.

If you want it to run at startup, you can copy the plist file into /Library/LaunchDaemons and start it with sudo launchctl load /Library/LaunchDaemons/com.samgentle.devrouter.plist

Once the Devrouter is running, you need to redirect some TLD to it. I suggest .dev. On OS X you can do that by putting this in /etc/resolver/dev:

nameserver 127.0.0.1
port 10053

.localhost is another good choice, and I'm told it works by default on Linux. Unfortunately, Chrome interprets requests for .localhost in the URL bar as searches by default unless you prefix them with http://. Luckily, Google also registered the .dev TLD, presumably as a very expensive workaround. Thanks, Google!

Usage

To use it, just type devroute <command-here>. Works great with http-server! devroute http-server

There are some more options you can check out with devroute --help, including setting a specific port and name

You can also put static routes in /etc/devrouter.json, they should look like this:

{
  "myserver": 1234
}

Which will permanently point myserver.dev (or myserver.localhost or whatever) to port 1234.

tl:dr (OSX)

npm install -g devrouter
sudo devrouter
sudo sh -c 'echo nameserver 127.0.0.1\\nport 10053 > /etc/resolver/dev'
cd my-project
devroute ./thing_that_runs_my_server
open http://my-project.dev

License

MIT