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

@scottwalker/node-framework

v2.1.4

Published

Node framework for typical tasks

Readme

Node Framework

Build Version NPM Package Scottweb

Простой и легковесный фреймворк для решения типовых задач

Установка

Первичное развертывание проекта

npm init -y
npm i @scottwalker/node-framework
cp -r ./node_modules/@scottwalker/node-framework/demo/* .
node .

Использование

Примеры базового использования фреймворка

Пример инициализации приложения (index.js)

const { Application, Container } = require("@scottwalker/node-framework")
const config = require("./config/main")
const modules = require("./modules")

// Инициализировать контейнер зависимостей
const container = new Container()

// Инициализировать приложение
const app = new Application(container, modules, config)

// Запустить приложение
app.run()

Пример простой конфигурации (config.js)

const path = require("path")

module.exports = {
  router: {
    options: {
      jsonResponse: true
    },
    headers: {
      "Content-Type": "application/json"
    },
    handler: ({ response }) => response.ok("default"),
    errorHandler: ({ response }) => response.error("error"),
  },
  logger: {
    dir: path.resolve(__dirname, "../logs"),
  },
  server: {
    host: "localhost",
    port: 3030,
    ssl: {}
  }
}

Конфигурация имеет основные секции

router - Конфигурация роутера
  options - опции маршрутов по умолчанию
    jsonResponse - отдавать тело ответа в формате JSON
  headers - HTTP заголовки ответа по умолчанию
  handler - Обработчик успешных запросов к модулю по умолчанию
  errorHandler - Обработчик неудачных запросов к модулю по умолчанию

logger - Конфигурация логгера
  dir - Директория для логов
  dateFormat - Обработчик формата даты в логах

server - Конфигурация сервера
  host - Хост сервера
  port - Порт сервера
  ssl - Настройки SSL соединения

Пример описания модулей приложения modules.js

const { Module } = require("@scottwalker/node-framework")

module.exports = [
  new Module("base", { 
    // Маршруты модуля
    routes: [
      {
        method: "GET", 
        path: "/", 
        handler: ({ response }) => response.ok("Hello World!"),
        errorHandler: ({ response }) => response.error("Goodbye World!"),
      },
    ],

    // Команды модуля
    commands: [
      {
        name: "base/hello",
        params: [
          { key: "name", type: "string", required: true },
          { key: "p", alias: "price", type: "number", default: 100 },
        ],
        flags: [
          { key: "q" },
          { key: "a", alias: "all" }
        ],
        handler: ({ params }) => {
          const { name, babki, all } = params 

          console.log({ name, babki, all })
        }
      }
    ],

    // Зависимости модуля
    dependencies: {
      "base/models/User": ({ name }) => new require("./models/User")(name)
    }
  })
]

Каждый модуль обязательно должен иметь свойства

routes - Описание маршрутизации модуля
dependencies - Описание зависимостей модуля

Контейнер зависимостей

В версии 2.0.1 значительно переделана структура фреймворка по причине использования контейнера зависимостей.

Контейнер зависимостей использует 2 стратегии получения внедренных зависимостей

invoke - Вызвать зависимость, которая при первом вызове создается по стратегии make, а при дальнейших invoke вызовах, используется инициализированный ранее экземпляр зависимости  
make - Создать новый экземпляр зависимости

Пример описания зависимостей приложения

const { Container } = require("@scottwalker/node-framework")

// Инициализировать контейнер зависимостей
const container = new Container({
  // Клиенты
  "app/clients/HttpClient": ({}, { host, strict }) => new require("./clients/HttpClient")(host, strict),
  "app/clients/MongoClient": ({}, { config }) => new require("./clients/MongoClient")(config),

  // Модели
  "app/models/CampaignModel": () => new require("./models/CampaignModel")(),
  
  // Репозитории
  "app/repositories/CampaignRepository": ({ invoke }) => {
    const CampaignRepository = require("./repositories/CampaignRepository")
    const mongoClient = invoke("app/clients/MongoClient")

    return new CampaignRepository(mongoClient)
  },

  // Сервисы
  "app/services/CampaignService": ({ invoke, make }) => {
    const CampaignService = require("./services/CampaignService")
    const httpClient = invoke("app/clients/HttpClient", { host: "localhost", strict: true })
    const campaignRepository = make("app/repositories/CampaignRepository")

    return new CampaignService(httpClient, campaignRepository, { logged: true })
  }
})

Командная оболочка

В версии 2.1.4 добавлен механизм для выполнения консольных команд приложения.

Пример инициализации консольного приложения

const { Shell } = require("@scottwalker/node-framework")
const config = require("./config/main")
const modules = require("./modules")
const container = require("./container")(config)

// Инициализировать командную оболочку
const shell  = new Shell(container, modules, config)

// Парсить переданные аргументы 
const { name, params } = shell.parse(process.argv)

// Выполнить команду
shell.exec(name, params)