0Pricing
NestJS Enterprise Backend APIs · درس

بنية المشروع وCLI

تعلّم تهيئة مشروع NestJS جديد باستخدام CLI، وافهم بنية المجلدات الافتراضية، وأنشئ المكونات بكفاءة.

بنية المشروع وCLI درس مجاني في NestJS Enterprise Backend APIs على CoddyKit. هذا هو الدرس 2 من أصل 3. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في NestJS Enterprise Backend APIs، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة NestJS Enterprise Backend APIs 3 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

NestJS CLI: Your Development Ally

The NestJS CLI is your dev assistant — it scaffolds projects, generates boilerplate for modules and services, and runs your builds.

Get the CLI Up and Running

Install the CLI globally with npm i -g @nestjs/cli (Node and npm required first). The -g flag makes the nest command available everywhere.

Starting a New NestJS App

Create a project with nest new my-first-backend. The CLI asks for a package manager, then sets up files, dependencies, and boilerplate.

Understanding the Project Layout

A new project's layout: src/ holds your code, node_modules/ the dependencies, test/ e2e tests, and dist/ the compiled output.

Core Application Files in `src`

Inside src/ are the core files: main.ts bootstraps the app, app.module.ts is the root module, plus a starter controller and service.

`main.ts`: Application Entry Point

main.ts is the entry point: NestFactory.create() builds the app and app.listen() starts the server, usually on port 3000.

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
  console.log(`Application is running on: ${await app.getUrl()}`);
}
bootstrap();

Building Blocks: A Simple Class

NestJS runs on classes — controllers, services, and modules are all TypeScript classes. This runnable snippet shows the basic class structure.

class Greeter {
  name: string;

  constructor(name: string) {
    this.name = name;
  }

  greet(): string {
    return `Hello, ${this.name}! Welcome to CoddyKit.`;
  }
}

// This is the entry point for running the example
function main() {
  const greeter = new Greeter("NestJS Learner");
  console.log(greeter.greet());
}

main();

Streamline with `nest generate`

As the app grows, use nest generate (or nest g) to scaffold modules, controllers, services, guards, pipes — and auto-wire them in.

CLI in Action: New Module

For a Users feature, run nest g module users. The CLI creates the folder and users.module.ts, then registers it in your root AppModule.

Test Your CLI Knowledge

You've learned about the NestJS CLI and how it helps set up and structure your project.

Which CLI command is used to quickly create a new NestJS project named my-api?

Summary: CLI & Project Setup

You used the CLI: installed it, created a project with nest new, explored the layout, and scaffolded components with nest generate.

الأسئلة الشائعة

هل درس «بنية المشروع وCLI» مجاني؟

نعم — نص درس «بنية المشروع وCLI» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة NestJS Enterprise Backend APIs، انتقل إلى CoddyKit PRO. تتضمن دورة NestJS Enterprise Backend APIs 3 دروس في المجموع.

ماذا ستتعلم في «بنية المشروع وCLI»؟

تعلّم تهيئة مشروع NestJS جديد باستخدام CLI، وافهم بنية المجلدات الافتراضية، وأنشئ المكونات بكفاءة. تتمرن على NestJS Enterprise Backend APIs مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ NestJS Enterprise Backend APIs؟

لا تُشترط خبرة سابقة. NestJS Enterprise Backend APIs على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 3.

كم من الوقت يستغرق درس «بنية المشروع وCLI»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس NestJS Enterprise Backend APIs هذا؟

نعم. كل درس في NestJS Enterprise Backend APIs يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. مقدمة إلى إطار NestJS
  2. بنية المشروع وCLI
  3. الوحدات ووحدات التحكم والخدمات
← العودة إلى NestJS Enterprise Backend APIs