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

kiss

v0.2.4

Published

HTTP/2 static server

Downloads

29

Readme

kiss

NPM version Build status Test coverage Dependency Status License Downloads Gittip

Keeping web development simple with a Koa-based HTTP/2 static server. This server seamlessly HTTP/2 pushes all your files dependencies! You never have to explicitly PUSH assets to the client (unless you want to).

KISS hopes to simplify web development further by being extensible. By using plugins for polyfilling, transpilation and, eventually, package management, your build system will eventually become nonexistent. Your server is the new build system.

Supported Dependency Types

The following types of dependencies are parsed and HTTP pushed:

HTML:

  • <script src> - scripts
  • <module src> - modules
  • <link rel="stylesheet"> - stylesheets
  • <link rel="import"> - HTML imports

CSS:

  • @import ""; - CSS imports

JS:

  • import '' - module imports

Dependencies that are conditional are not pushed automatically. If the client has a good chance of not using the dependency at all, extra latency is considered acceptable. Some examples are:

  • CSS url() dependencies, many of which are wrapped in @media or @support queries or conditional selectors.
  • CSS dependences with media queries including <link rel="stylesheet" media=""> and @import "" screen;.
  • JS System.import()s, which are always dynamically loaded.

Caveats

KISS only supports iojs.

iojs does not yet support HTTP2. The current implementation uses spdy, which will most likely be the precursor for iojs' HTTP2 implementation. SPDY is sufficient for testing and educational purposes.

When streaming HTML, this middleware will buffer the response in memory. This is required because the current dependency parser does not support streaming (and probably never will). This is not a big issue as you probably shouldn't be using streaming templating systems anyways.

KISS is not production-ready and will most likely not be production-ready for a while. KISS will not attempt to become production-ready until load balancers such as nginx support HTTP2 push from upstream servers.

Example

let koa = require('koa')
let app = koa()

let server = require('kiss')()
// mount the public folder at root
server.mount(__dirname + '/public')
// expose `/client`
server.mount('/client', __dirname + '/client')
app.use(server)

You can also view the example by cloning this repo and running ./bin/kiss example:

git clone git://github.com/kissweb/kiss
cd kiss
./bin/kiss example

Then opening the page in your browser:

open https://127.0.0.1:4000/

Be sure to accept the self-signed certificate!

kiss(1)

KISS comes with a CLI for serving with a hope of replacing serve. To install:

npm i -g kiss

And to run:

kiss .

Note that, by default, KISS uses a self-signed certificate. This is required as many browsers do not support HTTP2 without SSL. Acknowledge this from your browser to continue working.

Type the following for more information:

kiss --help

JS API

var server = new Kiss([root], options)

Create a new KISS instance.

var KISS = require('kiss')
var server = new KISS('public', {
  cacheControl: '1 year'
})

The root option is a shortcut for server.mount(root).

app.use(server)

You can use each instance:

app.use(server)

server.mount([prefix="/"], folder)

Mount a server path. For example:

  • .mount('public') -> GET /index.html -> public/index.html
  • .mount('/something', 'public') -> GET /something/index.html -> public/index.html

You never want to have more than a single instance of KISS on a server. By mounting multiple directories at once,

Folders resolve to the current working directory.

server.etag(fn)

Add a custom ETag function. By default, the etag module is used. Function signature is stats => <etag>.

server.cacheControl(maxAge)

Change the cache control header, which defaults to public, max-age=<1 year>. maxAge could either be a time in ms or a time string parsed using the ms module.

server.hidden(enable)

If hidden directories are supported, paths whose fragments begin with . are allowed. Instead of enabling this option, you should mount on paths like server.mount('/.git', '.git')