Angular-style schematics for the NestJS framework, enabling generation of application components through a command-line interface.
tessl install tessl/npm-nestjs--schematics@11.0.0NestJS Schematics provides Angular-style code generators for the NestJS framework, enabling developers to quickly scaffold application components, modules, and entire project structures through a command-line interface. Built on Angular DevKit schematics, it offers 20+ generators with TypeScript support, dependency injection setup, and standardized project patterns.
npm install -g @nestjs/cli (includes schematics) or npm install @nestjs/schematicsFor programmatic use:
import {
MetadataManager,
ModuleDeclarator,
NameParser,
DEFAULT_LANGUAGE,
PROJECT_TYPE
} from '@nestjs/schematics';Most users interact via the Nest CLI:
nest generate <schematic> <name> [options]
# or
ng generate @nestjs/schematics:<schematic> <name> [options]# Generate a new Nest application
nest new my-app
# Generate components
nest generate service users
nest generate controller auth --no-spec
nest generate module products
nest generate guard roles
# Generate resources with CRUD operations
nest generate resource posts --type=rest --crud
# Generate library in monorepo
nest generate library sharedimport { NameParser, ModuleDeclarator } from '@nestjs/schematics';
// Parse component names and paths
const parser = new NameParser();
const location = parser.parse({ name: 'user-service', path: 'src/users' });
// Declare module imports
const declarator = new ModuleDeclarator();
const updatedContent = declarator.declare(moduleContent, {
metadata: 'providers',
symbol: 'UserService',
type: 'class'
});NestJS Schematics is built around several key components:
Complete set of code generators for NestJS applications including controllers, services, modules, guards, pipes, filters, and more. Supports both standalone components and full applications with monorepo structures.
// Core application schematics
function application(options: ApplicationOptions): Rule;
function module(options: ModuleOptions): Rule;
function controller(options: ControllerOptions): Rule;
function service(options: ServiceOptions): Rule;
// Common schematic options pattern
interface BaseSchematicOptions {
name: string;
path?: string | Path;
module?: Path;
skipImport?: boolean;
metadata?: string;
language?: string;
sourceRoot?: string;
spec?: boolean;
specFileSuffix?: string;
flat?: boolean;
}Comprehensive toolkit for TypeScript/JavaScript code manipulation, module management, and project structure operations. Includes AST parsers, file system helpers, and NestJS-specific utilities.
class MetadataManager {
insert(metadata: string, symbol: string, staticOptions?: DeclarationOptions['staticOptions']): string | undefined;
}
class ModuleDeclarator {
declare(content: string, options: DeclarationOptions): string;
}
class NameParser {
parse(options: ParseOptions): Location;
}
interface DeclarationOptions {
metadata: string;
symbol: string;
type?: string;
staticOptions?: {
name: string;
value: string;
};
}Pre-configured default values and project type constants for consistent application generation.
const DEFAULT_LANGUAGE: string;
const DEFAULT_VERSION: string;
const DEFAULT_PATH_NAME: string;
const PROJECT_TYPE: {
LIBRARY: 'library';
APPLICATION: 'application';
};interface Location {
name: string;
path: Path;
}
interface ParseOptions {
name: string;
path?: string;
}
interface FindOptions {
name: string;
path: Path;
}
enum NodeDependencyType {
Default = 'dependencies',
Dev = 'devDependencies',
Peer = 'peerDependencies',
Optional = 'optionalDependencies'
}
interface NodeDependency {
type: NodeDependencyType;
name: string;
version: string;
overwrite?: boolean;
}