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

lws

v4.2.0

Published

A lean, modular web server for rapid full-stack development

Downloads

447,446

Readme

view on npm npm module downloads Gihub repo dependents Gihub package dependents Node.js CI js-standard-style

lws

A lean, modular web server for rapid full-stack development.

Lws is an application core for quickly launching a local web server. Behaviour is added via plugins giving you full control over how requests are processed and responses created.

  • Supports HTTP, HTTPS and HTTP2.
  • Small and 100% personalisable. Load and use only the behaviour required by your project.
  • Attach a custom view to personalise how activity is visualised.
  • Programmatic and command-line APIs.

Synopsis

Core usage

Launch an HTTP server on the default port of 8000.

$ lws
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000

For HTTPS or HTTP2, pass the --https or --http2 flags respectively.

$ lws --http2
Listening at https://mba4.local:8000, https://127.0.0.1:8000, https://192.168.0.200:8000

Now your server is running, the next step is to attach some middleware to process requests.

Using middleware plugins

Install and use some middleware (lws-static and lws-index) to serve static files and directory listings.

$ npm install --save-dev lws-static lws-index

$ lws --stack lws-static lws-index
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000

The current directory will now be available to explore at http://127.0.0.1:8000.

Install and use logging middleware. Note the lws- prefix is optional when supplying module names to --stack.

$ npm install --save-dev lws-log

$ lws --stack log static index --log.format combined
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000
::ffff:127.0.0.1 - GET /lws.config.js HTTP/1.1 200 52 - 8.259 ms
::ffff:127.0.0.1 - GET /package.json HTTP/1.1 200 399 - 1.478 ms

Creating a custom middleware plugin

Lws uses Koa as its middleware engine. Here is a trivial plugin example, save the following code as example-middleware.js:

class ExamplePlugin {
  middleware () {
    return async (ctx, next) => {
      ctx.body = 'Hello from lws!'
      await next()
    }
  }
}

export default ExamplePlugin

Now launch an HTTP server using this middleware.

$ lws --stack example-middleware.js
Listening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000

$ curl http://127.0.0.1:8000
Hello from lws!

Install

$ npm install --save-dev lws

Documentation

See also


© 2016-24 Lloyd Brookes <[email protected]>.

Tested by test-runner. Documented by jsdoc-to-markdown.