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

aliv

v1.13.0

Published

Simple, but powerful and intuitive one liner live-reloading Node.js server.

Downloads

175

Readme

Build Status Coverage Status npm version

It's alive! It's alive! In the name of God! Now I know what it feels like to be God! ~Frankenstein

What?

Light, fast and powerful one liner live-reloading Node.js server.

From the simplest live-reloading server to complex apps that need compression, proxies, middlewares and HTTP/2 - aliv got you covered.

Install

Globally:

$ npm i -g aliv

Locally:

$ npm i --save-dev aliv

Why?

Some similar modules out there are not as easy to setup, to maintain, or to extend. This one was made on demand for web development, more specific, to Single Page Applications. No more silly bugs when refreshing deep routes and then getting 404'd.

aliv simplifies a lot of headache we have when developing complex web apps.

  • Proxy request/responses;
  • Automagically gzip the response of your server;
  • Use HTTP/2 by simply setting http2 to true;
  • Refresh all your connected browsers with each file change;
  • Run a bunch of middlewares before each browser reload if you feel like it;
  • Use less memory/CPU possible.

How?

You can choose the way to work with aliv: CLI (terminal), aliv.config.js (Node module), .alivrc (config file) or a local node module.

Go to the folder that contains the index.html file and run:

$ aliv

There you go, all running!

Oh, do you want some specific stuff? Checkout the available options. If you need help with something more specific, feel free to check the wiki.

Options

Head over to the wiki to see all the options

CLI

--version, --v                   display version (only available on the CLI)
--port, --p                      change port
--host, --h                      change the host name
--secure, --s                    use https/wss
--http2, --h2                    use the new and improved version of the HTTP protocol
--cors, --c                      respond to requests with CORS headers, use true or object to override defaults
--quiet, --q                     no logging whatsoever
--noBrowser, --nb                won't open the browser automagically
--only, --o                      will only watch for changes in the given path/glob/regex/array
--ignore, --ign                  won't watch for changes in the given path (regex)
--pathIndex, --pi                change the path to your index.html
--proxy, --px                    uses proxy
--proxyTarget, --pxt             the http/https server where the proxy will "redirect"
--proxyWhen, --pxw               when the proxy should be activated; like --pxw /api/*
--root, --ro                     set the root to a different folder, like "./src/my/deep/folder/"
--watch, --w                     choose to watch for files change or not
--static, --st                   choose what paths are going to be served
--reloadDelay, --rd              time (in ms) to delay the browser refresh
--redirectHttpToHttps, --rhh     redirect any http traffic to https
--insecurePort, --insPort        inform an insecure port

aliv.config.js

All the options being used on the CLI can be added to the aliv.config.js file, like this:

module.exports = {
  port: 9999,
  quiet: true,
  cors: {
    headers: "Content-Type, Custom-Header",
    methods: "GET, OPTIONS",
    credentials: false
  },
  pathIndex: "src/",
  only: ["src/**/*"],
  proxy: true,
  proxyWhen: ["/api/*", "/cqrs/*"],
  proxyTarget: ["http://my-other-server.com:1234", "http://my-cqrs-server.com:1234"]
}

By doing that, when running $ aliv, it'll get all the options in aliv.config.js and use it.

But, if you have such file and still use something like $ aliv --port 9999, the cli will have priority over the file.

.alivrc

All the options being used on the CLI can be added to the .alivrc file, like this:

{
  "port": 9999,
  "quiet": true,
  "cors": {
    "headers": "Content-Type, Custom-Header",
    "methods": "GET, OPTIONS",
    "credentials": false
  },
  "pathIndex": "src/",
  "only": ["src/**/*"],
  "proxy": true,
  "proxyWhen": ["/api/*", "/cqrs/*"],
  "proxyTarget": ["http://my-other-server.com:1234", "http://my-cqrs-server.com:1234"]
}

By doing that, when running $ aliv, it'll get all the options in .alivrc and use it.

But, if you have such file and still use something like $ aliv --port 9999, the cli will have priority over the file.

Node module

const Server = require('aliv');

// yes, that easy - now your browser will open
// and it'll be refreshed every time a file changes
new Server({quiet: true}).start();

Default values

--port                  is 1307
--host                  is 127.0.0.1
--secure                is false
--http2                 is false
--cors                  is false
--quiet                 is false
--only                  is ".", which means it'll watch everything
--ignore                see list full regex in lib/options.js
--noBrowser             is false, which means it'll always open the browser on start
--pathIndex             is "", which means it'll look for the index.html in the root
--proxy                 is false, which means it'll not look for another server to answer for the /api/, for example
--proxyTarget           is "", no server to be target
--proxyWhen             is "", and it's supposed to be set with something like /api/*
--root                  is process.cwd()
--watch                 is true
--static                is [root, root + "/path/to/your/index"]
--reloadDelay           is 0
--redirectHttpToHttps   is false
--insecurePort          is 80

Wiki

Check the wiki for examples, FAQ, available options, troubleshooting and more.

Contributing

I've got an idea!

Great, let's talk!

I want to contribute

Awesome!

First, I'd suggest you open an issue so we can talk about the changes to be made and suchs and then you can do whatever you want :smile:

Also, there's the folder _fixture ready to be customized so you can try some stuff while modifying the code; just run npm start and have fun!

License

MIT