What is Nest Module?

Nest provides modules are high level components in the application. Modules are introduced to organize reusable features, and makes organizaiton of application effectively.

Module is a Typescript class annoted with @module decorator.

@module decorator contains module metadata of how components are exposed and used by other components.

NestJS application has atleast one module, Root module located in app.module.ts

How to create a module

Root module is created wit application creation.

You can create your own module using below command

nest g mo employee

It created a file employee.module.ts under a folder employee

import { Module } from '@nestjs/common';

 controllers: [],
 providers: [],
export class EmployeeModule {}

Updated this module in root module app.module.ts

import { Module } from '@nestjs/common';
import { EmployeeModule } from './employee/employee.module';

  imports: [EmployeeModule],
export class AppModule {}