0Pricing
NestJS Enterprise Backend APIs · Aula

Estrutura do Projeto e CLI

Aprenda a inicializar um novo projeto NestJS usando a CLI, compreenda a estrutura padrão de pastas e gere componentes com eficiência.

Estrutura do Projeto e CLI é uma aula grátis de NestJS Enterprise Backend APIs no CoddyKit. Esta é a aula 2 de 3. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de NestJS Enterprise Backend APIs, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de NestJS Enterprise Backend APIs inclui 3 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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.

Perguntas Frequentes

A aula “Estrutura do Projeto e CLI” é grátis?

Sim — o texto completo de “Estrutura do Projeto e CLI” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de NestJS Enterprise Backend APIs, atualize para CoddyKit PRO. O curso de NestJS Enterprise Backend APIs inclui 3 aulas no total.

O que vou aprender em “Estrutura do Projeto e CLI”?

Aprenda a inicializar um novo projeto NestJS usando a CLI, compreenda a estrutura padrão de pastas e gere componentes com eficiência. Você pratica NestJS Enterprise Backend APIs com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar NestJS Enterprise Backend APIs?

Nenhuma experiência prévia é necessária. NestJS Enterprise Backend APIs no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 3.

Quanto tempo leva a aula “Estrutura do Projeto e CLI”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de NestJS Enterprise Backend APIs?

Sim. Cada aula de NestJS Enterprise Backend APIs inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Introdução ao Framework NestJS
  2. Estrutura do Projeto e CLI
  3. Módulos, Controladores e Serviços
← Voltar para NestJS Enterprise Backend APIs