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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@application-kit/bootstrap

v0.2.3

Published

Бутстрап процессов NestJS: web на Fastify с периметром (доверенные прокси по хопам, request-id в каждом ответе, cookie, ValidationPipe с плоским списком ошибок, graceful shutdown) и CLI на nestjs-console с логгером pino

Readme

@application-kit/bootstrap

Бутстрап процессов NestJS: web на Fastify с периметром и CLI на nestjs-console. Состав модулей, Swagger, метрики, порт и число прокси перед приложением знает приложение: пакет собирает процесс из его корневого модуля и опций.

Установка

yarn add @application-kit/bootstrap

Peer-зависимости — @nestjs/common, @nestjs/core, nestjs-pino; остальные optional и нужны только своему входу. @application-kit/observability пакет приносит сам. Логгер обоих входов — nestjs-pino: его LoggerModule обязан быть в графе корневого модуля.

Входы

| Вход | Для чего | Тянет | |------|----------|-------| | @application-kit/bootstrap/web | createFastifyApplication — web-процесс на Fastify | @nestjs/platform-fastify, @fastify/cookie, class-validator, class-transformer, @opentelemetry/api | | @application-kit/bootstrap/cli | cliBootstrap — CLI-процесс | nestjs-console |

Корневого входа нет: web-процессу nestjs-console не нужен, CLI — Fastify.

Web

import { createFastifyApplication } from '@application-kit/bootstrap/web'

const app = await createFastifyApplication(AppModule, {
  configure: (app) => {
    setupMetricsHooks(app)
  },
  trustProxyHops: 2,
})
await app.listen(port, '0.0.0.0')

Периметр, который ставит пакет, по порядку:

  1. Fastify-адаптер: genReqId — x-request-id от прокси либо свой UUID (fastifyRequestId из @application-kit/observability/logging); доверенные прокси — первые trustProxyHops прыжков справа в X-Forwarded-For, так что адрес, подсунутый клиентом слева, request.ip не подменяет.
  2. @fastify/cookie с опциями cookie.
  3. Хук onRequest: заголовок x-request-id на каждый ответ, включая 404 и ошибки парсинга тела.
  4. configure(app) — настройка продукта.
  5. LoggerErrorInterceptor и логгер nestjs-pino для Nest; uncaughtException — в тот же лог.
  6. Shutdown hooks: по SIGTERM/SIGINT провайдеры закрываются, HTTP-сервер дожидается открытых соединений.
  7. Глобальный ValidationPipe с transform: true: невалидный DTO — статус validationErrorStatus и тело { statusCode, validationErrors: [{ property, constraints }] }, вложенное поле — путём parent.child.

| Опция | По умолчанию | | |-------|--------------|---| | trustProxyHops | 0 | сколько прокси перед приложением доверенные; 0 — только сокет | | validationErrorStatus | 422 | статус ответа на невалидный DTO | | cookie | {} | опции @fastify/cookie; false — плагин не регистрируется | | configure | — | (app) => void, зовётся после хука request-id, до интерцептора и пайпа |

CLI

import { cliBootstrap } from '@application-kit/bootstrap/cli'

void cliBootstrap(CliModule)

Команда берётся из process.argv, после неё приложение закрывается. Упавшая команда — запись уровня error с context: 'Console process failed.' и код выхода 1: cron и джоба кластера видят провал только по коду. Корневой модуль импортирует ConsoleModule из nestjs-console.