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

@bkeenke/shm-contract

v1.9.0

Published

API library for SHM (Service Hosting Manager). Can be used in backend and frontend.

Downloads

602

Readme

@bkeenke/shm-contract

TypeScript/Zod контракты для SHM API. Используется для типизации запросов и ответов API на фронтенде

Установка

npm install @bkeenke/shm-contract
# или
yarn add @bkeenke/shm-contract

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

Импорт типов и схем

import {
  // Models (Zod schemas + types)
  User,
  UserSchema,
  Service,
  ServiceSchema,

  // API routes
  REST_API,

  // Commands
  AuthLoginCommand,
  AdminGetUsersCommand,

  // Constants
  USER_SERVICE_STATUS,
  SPOOL_STATUS,
} from '@bkeenke/shm-contract';

Пример использования с axios

import axios from 'axios';
import { AuthLoginCommand, REST_API } from '@bkeenke/shm-contract';

async function login(credentials: AuthLoginCommand.Request) {
  // Валидация входных данных
  const validated = AuthLoginCommand.RequestSchema.parse(credentials);

  const response = await axios.post(AuthLoginCommand.url, validated);

  // Валидация ответа
  return AuthLoginCommand.ResponseSchema.parse(response.data);
}

Пример использования с TanStack Query

import { useQuery } from '@tanstack/react-query';
import { AdminGetUsersCommand } from '@bkeenke/shm-contract';

function useUsers() {
  return useQuery({
    queryKey: ['users'],
    queryFn: async () => {
      const response = await fetch(AdminGetUsersCommand.url);
      const data = await response.json();
      return AdminGetUsersCommand.ResponseSchema.parse(data);
    },
  });
}

Структура пакета

@bkeenke/shm-contract/
├── api/              # API routes и controllers
│   ├── routes.ts     # Все API маршруты
│   └── controllers.ts
├── constants/        # Константы
│   ├── user-service-status.constant.ts
│   ├── spool-status.constant.ts
│   └── http-method.constant.ts
├── models/           # Zod схемы и типы
│   ├── user.schema.ts
│   ├── service.schema.ts
│   ├── pay.schema.ts
│   └── ...
└── commands/         # API команды (контракты)
    ├── auth/
    ├── users/
    ├── services/
    ├── servers/
    ├── spool/
    ├── pay/
    ├── templates/
    ├── storage/
    ├── config/
    ├── promo/
    └── telegram/

API Routes

Все маршруты доступны через объект REST_API:

import { REST_API } from '@bkeenke/shm-contract';

// User routes
REST_API.USER.GET        // GET /shm/v1/user
REST_API.USER.AUTH       // POST /shm/v1/user/auth
REST_API.USER.SERVICE    // GET/DELETE /shm/v1/user/service

// Admin routes
REST_API.ADMIN.USER.ROOT       // CRUD /shm/v1/admin/user
REST_API.ADMIN.SERVICE.ROOT    // CRUD /shm/v1/admin/service
REST_API.ADMIN.SERVER.ROOT     // CRUD /shm/v1/admin/server
REST_API.ADMIN.SPOOL.ROOT      // CRUD /shm/v1/admin/spool
REST_API.ADMIN.TEMPLATE.ROOT   // CRUD /shm/v1/admin/template
REST_API.ADMIN.CONFIG.ROOT     // CRUD /shm/v1/admin/config
REST_API.ADMIN.PROMO.ROOT      // CRUD /shm/v1/admin/promo

Commands (Контракты)

Каждая команда содержит:

  • url - URL эндпоинта
  • method - HTTP метод
  • RequestSchema - Zod схема запроса
  • ResponseSchema - Zod схема ответа
  • Request - TypeScript тип запроса
  • Response - TypeScript тип ответа

Auth Commands

  • AuthLoginCommand - Авторизация
  • AuthRegisterCommand - Регистрация
  • TelegramWebappAuthCommand - Авторизация через Telegram WebApp
  • PasskeyAuthCommand - Авторизация через Passkey

User Commands

  • GetCurrentUserCommand - Получить текущего пользователя
  • UpdateCurrentUserCommand - Обновить профиль
  • ChangePasswordCommand - Сменить пароль

Admin Commands

  • AdminGetUsersCommand - Список пользователей
  • AdminCreateUserCommand - Создать пользователя
  • AdminGetServicesCommand - Список услуг
  • AdminGetServersCommand - Список серверов
  • AdminGetSpoolCommand - Список задач
  • и другие...

Разработка

# Установка зависимостей
npm install

# Сборка
npm run build

# Watch mode
npm run dev

Лицензия

MIT