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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dispense

v1.0.1

Published

NodeJS server with express boilerplate

Readme

░█▀▄░▀█▀░█▀▀░█▀█░█▀▀░█▀█░█▀▀░█▀▀
░█░█░░█░░▀▀█░█▀▀░█▀▀░█░█░▀▀█░█▀▀
░▀▀░░▀▀▀░▀▀▀░▀░░░▀▀▀░▀░▀░▀▀▀░▀▀▀

npm version

Простой HTTP-сервер на Node.js + Express для быстрого поднятия локального сервера.
Основной кейс: есть папка public (или любая другая) — нужно быстро начать её раздавать.

CLI-команда: dispense run

Install

# Глобально (удобно для быстрого использования везде)
npm install -g dispense

# Локально в проект (dev-зависимость)
npm install dispense

Fast start

# Если установлен глобально
dispense run

# Если установлен локально
npx dispense run

CLI options

dispense run [options]
 -a,   --api <path>         путь до файла с вашим кастомным роутером для api (дефолтный для Express синтаксис)
 -p,   --port <number>      порт (default 3000 или process.env.PORT)
 -d,   --public <path>      папка со статикой (default ./public)
 -nsh, --no-sec-headers     отключить security-заголовки
 -o,   --origins <list>     список origin для API CORS (separated by ,)
 -h,   --help               показать помощь

Examples:

# По умолчанию
dispense run              # раздаёт ./public

# Другая папка
dispense run --public ./dist

# Порт 4000, статика из ./your-dir
dispense run --port 4000 --public ./your-dir

# Без security-заголовков
dispense run --no-sec-headers

# Явный список origin для /api
dispense run --allowed-origins http://localhost:3000,https://example.com

# Важно: путь считается от текущей директории, где вы запускаете команду
cd /path/to/project
dispense run --public ./build

Custom API router

По умолчанию dispense использует встроенный роутер под /api. Можно передать свой роутер (файл/папку), который экспортирует Express Router:

// custom-api-router.js
import { Router } from 'express';

const router = Router({ mergeParams: true });

router.get('/ping', (req, res) => {
  res.json({ ok: true });
});

export default router;

Запуск с кастомным роутером:

dispense run --api-router ./custom-api-router.js

Путь считается от текущей рабочей директории.

Enviroment

# Если не указывать --port, берётся PORT или 3000
PORT=8080 dispense run

# Можно комбинировать с другими параметрами
PORT=5000 dispense run --public ./Public

Start via PM2

# Установка (если ещё нет)
npm install -g pm2 dispense

# Запуск
pm2 start dispense --name dev-server -- run --port 3000 --public ./Public

# Управление
pm2 restart dispense
pm2 stop dispense
pm2 delete dispense

Корректно обрабатываются SIGINT, SIGTERM и shutdown от PM2 (graceful shutdown).

Start from cloned repo

# После клонирования репо
npm install
npm start       # эквивалентно: node ./bin/run.js run
npx dispense    # при установке из репо - тоже работает


# Ручной запуск с параметрами
node ./bin/run.js run --port 4000 --public ./Public

Files descriptions

  • server.js — создание и запуск Express-сервера (createServer, startServer).
  • bin/run.js — CLI-обвязка (команда server).
  • public/* — Раздача статики + роутер фронтенда
  • Базовый API под /api.
  • Примеры middlewares - примитивная проверка клиента и basicAuth (при установке из NPM недоступно)
  • CORS + security-заголовки (можно выключить).
  • Логирование ошибок и аккуратное завершение работы.

License

MIT