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

@asadullohe/generator-crud

v1.2.2

Published

Swagger/OpenAPI asosida CRUD module generator

Readme

Generator CRUD

generator-crud Swagger/OpenAPI hujjatidan src/modules/... uchun CRUD modul generatsiya qiladi.

O'rnatish

pnpm add -D @asadullohe/generator-crud

Install qilinganda target project root'ida generate-crud.config.json default qiymatlar bilan yaratiladi. Agar package manager install scriptlarini o'tkazib yuborsa, pnpm generate-crud birinchi ishga tushganda ham config faylni yaratadi. Mavjud fayl ustidan yozilmaydi.

Target project package.jsoniga script qo'shish:

{
  "scripts": {
    "generate-crud": "generator-crud crud",
    "crud:generate-template": "generator-crud template"
  }
}

CRUD generatsiya qilish:

pnpm generate-crud

standard template package ichida bor. Oddiy CRUD generatsiya uchun avval template command ishlatish shart emas.

Script qo'shmasdan to'g'ridan-to'g'ri ishlatish ham mumkin:

pnpm exec generator-crud crud

Config faylni qo'lda yaratish kerak bo'lsa:

pnpm exec generator-crud init

Ishlatish

Generator har doim target loyiha root'idan ishga tushiriladi. Ya'ni cwd sifatida CRUD generatsiya qilinadigan repo turishi kerak.

Swagger URL va auth ma'lumotlarini har safar kiritmaslik uchun target project root'ida generate-crud.config.json yaratish mumkin:

{
  "swaggerUrl": "",
  "definitionName": "",
  "auth": {
    "mode": "none"
  }
}

Keyin:

SWAGGER_USERNAME=login SWAGGER_PASSWORD=parol pnpm generate-crud

Yoki target project root'ida .env fayl yaratish mumkin:

SWAGGER_USERNAME=login
SWAGGER_PASSWORD=parol

Login/parolni configga bevosita yozish ham mumkin, lekin repositoryga commit qilinadigan projectlarda env ishlatish tavsiya qilinadi.

Swagger UI ichida bir nechta definition bo'lsa, generator ularni ro'yxat qilib tanlatadi. Aniq definitionni config orqali berish ham mumkin:

{
  "definitionName": "Service V1"
}

Yoki to'g'ridan-to'g'ri spec URL:

{
  "definitionUrl": "https://example.com/service/v3/api-docs/Service%20V1"
}

serviceKey yozish shart emas. Generator Swagger/OpenAPI servers ro'yxatini chiqaradi, tanlangan server /service-name bo'lsa serviceKey avtomatik serviceName bo'ladi. Agar majburan berish kerak bo'lsa:

{
  "serviceKey": "serviceName"
}

Auth mode variantlari:

Auth yo'q:

{
  "auth": {
    "mode": "none"
  }
}

Basic auth:

{
  "auth": {
    "mode": "basic",
    "usernameEnv": "SWAGGER_USERNAME",
    "passwordEnv": "SWAGGER_PASSWORD"
  }
}

Bearer token:

{
  "auth": {
    "mode": "bearer",
    "tokenEnv": "SWAGGER_TOKEN"
  }
}

Login endpoint orqali token olish:

{
  "auth": {
    "mode": "login",
    "authUrl": "https://example.com/auth/login",
    "authMethod": "POST",
    "usernameEnv": "SWAGGER_USERNAME",
    "passwordEnv": "SWAGGER_PASSWORD",
    "loginField": "username",
    "passwordField": "password",
    "tokenPath": "accessToken"
  }
}

Misol:

cd /path/to/target-project
pnpm generate-crud

Custom module pattern asosida yangi template saqlash kerak bo'lsa:

pnpm crud:generate-template

Template oqimi

template command:

  • source patternni project ichidan scan qiladi
  • topilgan patternlardan birini tanlatadi yoki custom path qabul qiladi
  • template nomini so'raydi
  • template'ni saqlaydi
  • active template'ni yangilaydi

Saqlanadigan joylar:

  • saqlangan template'lar: _templates/crud-module-store/<templateName>
  • active template: _templates/crud-module

crud command:

  • agar projectda template bo'lmasa, package ichidagi standard template'ni avtomatik aktiv qiladi
  • bir nechta saqlangan template bo'lsa, qaysi biri bilan ishlashni tanlatadi
  • configda bo'lmasa Swagger/OpenAPI URL so'raydi
  • configda bo'lmasa auth ma'lumotlarini oladi
  • Swagger UI ichida bir nechta definition bo'lsa, definition tanlatadi
  • select savollarida 0, text savollarida :back orqali oldingi stepga qaytish mumkin
  • tag va operationlarni tanlatadi
  • generatsiya scope'ini tanlatadi: full CRUD, bitta hook, bitta forma yoki bitta mutation
  • partial scope tanlansa mavjud modulga append qilish yoki yangi modul yaratishni tanlatadi
  • src/modules/... ichiga CRUD modul generatsiya qiladi yoki mavjud modulni yangilaydi

Qo'llab-quvvatlanadigan config fayllar:

  • generate-crud.config.json
  • generate-crud.config.mjs
  • generate-crud.config.js

Custom config path berish:

pnpm generate-crud --config=./crud.config.json

Qo'llab-quvvatlanadigan holatlar

  • list, single, create, update, delete
  • full CRUD yoki alohida artifact generatsiyasi: useList, useInfiniteList, useSingle, useDelete, form yoki mutation
  • alohida artifactni mavjud modulga append qilish
  • sync, upload, va boshqa custom mutation/form operationlar
  • multilingual fieldlar uchun getMultiName / getMultiNameSchema
  • Swagger/OpenAPI enum fieldlari uchun module constants.ts ichida as const options va type generatsiya qilish
  • relation mapper suggestion: registry, module scan, yoki manual mapper path orqali

Publish

Package publish uchun kerakli fayllar files orqali cheklangan:

  • bin
  • lib
  • _templates
  • build-template.mjs
  • generate-crud.mjs
  • README.md