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

distra

v0.1.7

Published

A vhost proxy doodad thing.

Downloads

12

Readme

distra

distra is a tool for building websites.

Use it to serve static files and directories, and to give servers running on your computer nice URLs. Set up hosts and routes using JSON, and then feel like a boss.

It also adds to your hosts file (safely) so you never have worry about that either!

Why?

I had so many servers running, particularly serving static files, that I never knew what was being served and on which port. So I built this so I'd never have to care again!

Super-quick setup

Install and start distra on port 80:

$ npm install -g distra
$ sudo distra 80

In another window, find some static files and set distra up to serve them:

$ cd some-project
$ distra add
Host http://some-project/ pointing to /path/to/some-project added.

Done.

Install

Distra requires:

  • OS X (yeah, sorry)
  • Node
  • npm
$ npm install -g distra
$ distra

Wahey! You're up, but it won't do much yet – you need to configure it.

Configuration

Distra is configured from the .distra.json file in your home directory, but you don't ever have to touch this file if you don't want to.

Adding a host

To add a host, use distra add.

$ distra add [host] [directory or url]

The host and directory or url are both optional. If you omit directory or url distra will serve your current directory.

If you omit both, distra will serve the current directory with the name of the directory as the host.

Try it:

Head to a directory with some .html files in it, lets say it's called website.

$ distra add

Assuming distra is started (just use distra), you will find that you can go to http://website:9876/ to access those files.

Removing a host

To remove a host, use distra rm.

$ distra rm [host]

Again, host is optional - it will just use the directory name if you don't supply one.

The config file

Distra writes its configuration to a config file found at ~/.distra.json.

Here's an example.

{
  "mysite.dev":   "localhost:4000",
  "project":      "/Users/you/sites/project"
}

In the example above, requests made to mysite.dev will be proxied through to the server running on port 4000 (a Jekyll server, perhaps). Requests made to project will be served static files from the directory specified.

You can view your current config using distra config:

$ distra config
mysite.dev        : localhost:4000
project           : /Users/you/sites/project

Tips

Ports

You can specify the port on which you want distra to start.

$ distra 1337

Portsaway!

I recommend starting on port 80 so you don't have to mess around with ports!

$ sudo distra 80

Tab Completion

If you use bash or zsh, why not bring tears of joy to your eye-holes and enable distra's tab completion?

Just add . <(distra completion) to your ~/.bashrc or ~/.zshrc. Hot.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE