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

lesky

v2.0.1

Published

Lightweight Express-ish (Koa) Server - Type les not More!

Downloads

41

Readme

npm npm NPM

Lightweight Express-ish (Koa) Server -- Type les not more!

Super configurable, easy-to-use lightweight Koa Server that lets you

  1. Statically serve any directory with les (not more).

--> If the directory contains a .lesrc config file, it will be used (FYI, the "rc" suffix stands for "run commands", a typical convention in Linux)

--> If CLI args are provided, those will be used

--> If both .lesrc and CLI args are provided, both will be used, but the CLI args will get priority.

  1. Init a Koa application in any directory with les --init (EASY)

--> The actual server.js boilerplate is kept separate from app.js, so you can focus more on your app and less on boilerplate!

Installation

npm i -g lesky

(I wanted les, but it was taken. No worries though...the "k" in the name makes it a little more accurate) (Global installation is recommended...install only once)

Usage

Make sure the "les" binary is discoverable. I.e., your PATH env var should be set up to include ~/.npm-global/bin:

export PATH=~/.npm-global/bin:$PATH

Then, from any folder launching a static server is simply:

les

Want to start it with even less pain (i.e., less "ouch"?)

les -ow

If there is a default "public" folder in your current working directory, that will be served. The default server can be accessed at: http://localhost:8080

Want to use lesky in YOUR native language? Now you can! (If the language set is in locales folder, you can use it!). If your system's language includes the two-letter language code it will be used; most systems should have the env var "LANG" set. If LANG is not set, simply set it two the language you want to use:

LANG="es" les

This will respect options in Spanish and display console messages back in that language.

Customizing (CLI)

The latest CLI options can always be found in the help menu:

les --help

usage: les [path] [options]

options:
	-h,	--help	Print this help menu
	-i,	--init	Init lesky in workspace specified by path, defaults to cwd [[cwd]]
	-a,	--host	Address to use [localhost]
	-p,	--port	Port to use [8080]
		--proto	Protocol to use [http] ({ http, https, http2 })
		--range	Port Range (in case port is taken) [8000,9000]
		--sslKey	Path to SSL Key
		--sslCert	Path to SSL Certificate
	-o,	--open	Open browser [OS default]
	-w,	--watch	Watch for file changes in dir [staticDir]

---End of Help---

LANG="es" les --ayuda

el uso de: les [path] [options]

options:
	-h,	--ayuda	Imprime este menú de ayuda
	-i,	--init	Init lesky en el espacio de trabajo especificado por la ruta por defecto cwd [[cwd]]
	-a,	--host	Dirección [localhost]
	-p,	--puerto	El puerto a utilizar [8080]
		--proto	Protocolo para el uso de [http] ({ http, https, http2 })
		--range	Rango de puertos (en caso de que el puerto se toma). Formato de inicio-final [8000,9000]
		--sslKey	Ruta de acceso de la Clave SSL
		--sslCert	Ruta de acceso a los Certificados SSL
	-o,	--abierto	Abra el navegador. [OS default]
	-w,	--reloj	Reloj para los cambios de los archivos en el directorio [staticDir]

---Fin de Ayudar a---

Customizing (.lesrc config file)

If a .lesrc config file is in the current working directory, it will be consumed. If CLI args are also provided, those will override the entry in .lesrc that matches protocol used by the CLI. The config file is simply a JSON file, specifying an array of configurations to use. If a desired port is already taken, an attempt will be made to find a free port.

Example .lesrc file:

[{
  "host": "localhost",
  "proto": "http2",
	"port": 8000,
  "sslKey": ".ssl/server.key",
  "sslCert": ".ssl/server.crt"
},{
  "proto": "https",
  "portRange": [8000, 9000]
}]

If using a language different from English, you can your language for the options in the file. So "port" could be written as "puerto" if Spanish is being. English will always be the fallback.

Initializing a workspace to be a lesky app

If it is desired to initialize the current workspace as a lesky app, it's accomplished by:

les [path] --init [options]

Where path defaults to the current working directory if not specified. The options passed in are the same as those passed to the CLI above. The only difference is that these options will be used to initialize the .lesrc config file that gets copied over, so that when you start the app, it will use your provided settings.

Specifically, running this command will initialize a package.json file in your workspace with useful scripts and dependencies (such as Koa). Then it will copy over several sample files, including server.js and app.js which will be the entry point. It will also automatically install the dependencies.

Protections in place: if package.json or .lesrc already exist in the destination folder, they will not be overwritten.

When initialization is done, the following should work:

npm start

npm run dev

TODO Items and Notes

  • I think some utils can still be transferred over to les-utils, where they'd be more reusable.

  • The les.js file has the i18n support while the others don't. I may want to carry over the translations to the other files, but I would like to do so gracefully. If someone runs les --init in a new workspace, it would have to copy over the preferred language set (I'll revisit someday)