Bu blog post bilan siz NestJS loyihasini boshlashni o'rganasiz. Biz, tajribangiz qanday bo'lishidan qat'i nazar, bu progresiv Node.js frameworkini o'rnatishni ko'rsatamiz. NestJS ilovasining mustahkam tuzilishini - kontrollerlarni, xizmatlarni, va modullarni qanday aniqlash kerakligini sodda ko'rinishini qarab chiqamiz. Testlash va sodda REST API nuqtasini yaratish haqida qisqa malumot bilan yakunlaymiz. Agar siz back-end dasturlashga yangi yoki NestJS-ga o'tishni xohlaysangiz bu qo'llanma sizga loyihani boshlash uchun kerak bo'ladigan asosiy bilimlarni beradi. Keling, NestJS dunyosiga birgalikda chuqurroq kirib boramiz!

nestjs

Oldingi post

Avvalam bor bizda node.js biz ishlayotgan komputerga o'rnatilganligini tekshirib olamiz. Bizga quydagi buyruq bilan buni amalga oshirishimiz mumkin.

bash
sh
~/Projects
node -v
v18.12.0

Demak hozir menda node.js'ning 18.12.0 versiyasi o'rnatilgan ekan:

Agar siz node.js'ni o'rnatishni bilmasangiz, buni quydagi ilova orqali bililib olishingiz mumkin: Node.js'ni o'rnatish

Agar bizda node.js o'rnatilgan bo'lsa, biz keyingi qadamlarga o'tamiz. Biz node.js ni o'rnatganimizda, node.js paketlar menejeri (Node Package managers) qo'shimchasi o'rnatilgan boladi, va bu bizga npm buyrug'ini taqdim qiladi, lekin boshqa, yarn va pnpm nomli menejerlar ham mavjud va men pnpm dan foydalangan holda, komputerimga global ravishda, NestJS dasturlarini boshqarish menejer dasturini o'rnatib olaman:

.
sh
~/Projects
pnpm i -g @nestjs/cli@latest

Packages: +174
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

/Users/adhammuhammadjonov/Library/pnpm/global/5:
+ @nestjs/cli 10.1.7

Progress: resolved 333, reused 329, downloaded 4, added 174, done
Done in 10.2s

Va biz NestJS menejerini shu tariqa o'rnatib olamiz. Biz endi nest new buyrug'idan foydalangan holda yangi loyha yartishimiz mumkin:

.
sh
~/Projects
nest new test-app

va bu buyruq bizga quydagi qaysi paket menejeridan foydalanishimizni so'raydi

.
sh
~/Projects

nest new test-app
  We will scaffold your app in a few seconds..

? Which package manager would you ❤️  to use?
  npm
  yarn
 pnpm

va men boshqaruv tugmasidan foydalanib pnpmni tanladim va enter tugmasini bsoqanimdan so'ng

bash
sh
~/Projects
  We will scaffold your app in a few seconds..

? Which package manager would you ❤️  to use? pnpm
CREATE test-app/.eslintrc.js (663 bytes)
CREATE test-app/.prettierrc (51 bytes)
CREATE test-app/README.md (3347 bytes)
CREATE test-app/nest-cli.json (171 bytes)
CREATE test-app/package.json (1953 bytes)
CREATE test-app/tsconfig.build.json (97 bytes)
CREATE test-app/tsconfig.json (546 bytes)
CREATE test-app/src/app.controller.spec.ts (617 bytes)
CREATE test-app/src/app.controller.ts (274 bytes)
CREATE test-app/src/app.module.ts (249 bytes)
CREATE test-app/src/app.service.ts (142 bytes)
CREATE test-app/src/main.ts (208 bytes)
CREATE test-app/test/app.e2e-spec.ts (630 bytes)
CREATE test-app/test/jest-e2e.json (183 bytes)

 Installation in progress...
🚀  Successfully created project test-app
👉  Get started with the following commands:

$ cd test-app
$ pnpm run start


                          Thanks for installing Nest 🙏
                 Please consider donating to our open collective
                        to help us maintain this package.


               🍷  Donate: https://opencollective.com/nest

bunday natija ko'rinadi, demak biz muvoffaqiyatli yangi loyahimizni boshlab oldik.

Agar biz o'zimiz tanglagan kod yozish dasturida ushbu loyihani ochsak quydagicha fayillarni ko'rishimiz mumkin:

NestJS dasturi fayillari

NestJS dasturi fayillari

Keyini postlarimizda biz bu fayillarning vazifalari bilan tanishib chiqamiz.

Keyingi post