or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.mdschematics.mdutilities.md

schematics.mddocs/

0

# Schematics Collection

1

2

Complete collection of 20+ code generators for NestJS applications, providing standardized component creation with TypeScript support, dependency injection setup, and consistent project structure.

3

4

## Capabilities

5

6

### Common Options

7

8

All component schematics share common configuration options:

9

10

```typescript { .api }

11

interface BaseSchematicOptions {

12

/** Component name */

13

name: string;

14

/** Target path for generation */

15

path?: string | Path;

16

/** Module to import the component into */

17

module?: Path;

18

/** Skip importing into module */

19

skipImport?: boolean;

20

/** Metadata type for module declaration */

21

metadata?: string;

22

/** Programming language (ts/js) */

23

language?: string;

24

/** Source root directory */

25

sourceRoot?: string;

26

/** Generate spec files */

27

spec?: boolean;

28

/** Spec file suffix */

29

specFileSuffix?: string;

30

/** Generate in flat structure */

31

flat?: boolean;

32

}

33

34

// Angular DevKit Types

35

type Path = string;

36

type Tree = import('@angular-devkit/schematics').Tree;

37

type SchematicContext = import('@angular-devkit/schematics').SchematicContext;

38

type Rule = (tree: Tree, context: SchematicContext) => Tree | Observable<Tree> | void;

39

type Observable<T> = import('rxjs').Observable<T>;

40

```

41

42

### Application Schematics

43

44

#### Application Generator

45

46

Creates a complete NestJS application with project structure, configuration, and dependencies.

47

48

```typescript { .api }

49

/**

50

* Generate a new NestJS application

51

* @param options - Application configuration options

52

* @returns Angular DevKit Rule for application generation

53

*/

54

function application(options: ApplicationOptions): Rule;

55

56

interface ApplicationOptions {

57

name: string | number;

58

author?: string;

59

description?: string;

60

directory?: string;

61

strict?: boolean;

62

version?: string;

63

language?: string;

64

packageManager?: 'npm' | 'yarn' | 'pnpm' | 'undefined';

65

dependencies?: string;

66

devDependencies?: string;

67

spec?: boolean;

68

specFileSuffix?: string;

69

}

70

```

71

72

**Usage Examples:**

73

74

```bash

75

# Generate new application

76

nest new my-app

77

78

# With custom options

79

nest new my-app --strict --package-manager=yarn

80

```

81

82

#### Library Generator

83

84

Creates a library within a monorepo structure.

85

86

```typescript { .api }

87

/**

88

* Generate a Nest library for monorepo projects

89

* @param options - Library configuration options

90

* @returns Angular DevKit Rule for library generation

91

*/

92

function library(options: LibraryOptions): Rule;

93

94

interface LibraryOptions extends BaseSchematicOptions {

95

name: string;

96

}

97

```

98

99

**Usage Examples:**

100

101

```bash

102

# Generate library

103

nest generate library shared

104

105

# With alias

106

nest g lib utils

107

```

108

109

#### Sub-Application Generator

110

111

Creates a sub-application within a monorepo.

112

113

```typescript { .api }

114

/**

115

* Generate a sub-application for monorepo projects

116

* @param options - Sub-application configuration options

117

* @returns Angular DevKit Rule for sub-application generation

118

*/

119

function subApp(options: SubAppOptions): Rule;

120

121

interface SubAppOptions extends BaseSchematicOptions {

122

name: string;

123

}

124

```

125

126

**Usage Examples:**

127

128

```bash

129

# Generate sub-application

130

nest generate sub-app api

131

132

# With alias

133

nest g app admin

134

```

135

136

### Core Component Schematics

137

138

#### Module Generator

139

140

Creates NestJS modules with proper decorator setup and file structure.

141

142

```typescript { .api }

143

/**

144

* Generate a Nest module

145

* @param options - Module configuration options

146

* @returns Angular DevKit Rule for module generation

147

*/

148

function module(options: ModuleOptions): Rule;

149

150

interface ModuleOptions extends BaseSchematicOptions {

151

name: string;

152

}

153

```

154

155

**Usage Examples:**

156

157

```bash

158

# Generate module

159

nest generate module users

160

161

# Generate without importing to parent module

162

nest g mo products --skip-import

163

```

164

165

#### Controller Generator

166

167

Creates NestJS controllers with routing and dependency injection setup.

168

169

```typescript { .api }

170

/**

171

* Generate a Nest controller

172

* @param options - Controller configuration options

173

* @returns Angular DevKit Rule for controller generation

174

*/

175

function controller(options: ControllerOptions): Rule;

176

177

interface ControllerOptions extends BaseSchematicOptions {

178

name: string;

179

}

180

```

181

182

**Usage Examples:**

183

184

```bash

185

# Generate controller

186

nest generate controller auth

187

188

# Generate without spec file

189

nest g co users --no-spec

190

191

# Generate in specific path

192

nest g co admin/users --path=src/admin

193

```

194

195

#### Service Generator

196

197

Creates NestJS services (providers) with dependency injection setup.

198

199

```typescript { .api }

200

/**

201

* Generate a Nest service

202

* @param options - Service configuration options

203

* @returns Angular DevKit Rule for service generation

204

*/

205

function service(options: ServiceOptions): Rule;

206

207

interface ServiceOptions extends BaseSchematicOptions {

208

name: string;

209

}

210

```

211

212

**Usage Examples:**

213

214

```bash

215

# Generate service

216

nest generate service users

217

218

# Generate with flat structure

219

nest g s auth --flat

220

```

221

222

#### Provider Generator

223

224

Creates generic NestJS providers.

225

226

```typescript { .api }

227

/**

228

* Generate a Nest provider

229

* @param options - Provider configuration options

230

* @returns Angular DevKit Rule for provider generation

231

*/

232

function provider(options: ProviderOptions): Rule;

233

234

interface ProviderOptions extends BaseSchematicOptions {

235

name: string;

236

}

237

```

238

239

### HTTP and Request Handling

240

241

#### Guard Generator

242

243

Creates NestJS guards for route protection and authorization.

244

245

```typescript { .api }

246

/**

247

* Generate a Nest guard

248

* @param options - Guard configuration options

249

* @returns Angular DevKit Rule for guard generation

250

*/

251

function guard(options: GuardOptions): Rule;

252

253

interface GuardOptions extends BaseSchematicOptions {

254

name: string;

255

}

256

```

257

258

**Usage Examples:**

259

260

```bash

261

# Generate guard

262

nest generate guard auth

263

264

# Generate with alias

265

nest g gu roles

266

```

267

268

#### Interceptor Generator

269

270

Creates NestJS interceptors for request/response transformation.

271

272

```typescript { .api }

273

/**

274

* Generate a Nest interceptor

275

* @param options - Interceptor configuration options

276

* @returns Angular DevKit Rule for interceptor generation

277

*/

278

function interceptor(options: InterceptorOptions): Rule;

279

280

interface InterceptorOptions extends BaseSchematicOptions {

281

name: string;

282

}

283

```

284

285

**Usage Examples:**

286

287

```bash

288

# Generate interceptor

289

nest generate interceptor logging

290

291

# Generate with alias

292

nest g itc transform

293

```

294

295

#### Pipe Generator

296

297

Creates NestJS pipes for data transformation and validation.

298

299

```typescript { .api }

300

/**

301

* Generate a Nest pipe

302

* @param options - Pipe configuration options

303

* @returns Angular DevKit Rule for pipe generation

304

*/

305

function pipe(options: PipeOptions): Rule;

306

307

interface PipeOptions extends BaseSchematicOptions {

308

name: string;

309

}

310

```

311

312

**Usage Examples:**

313

314

```bash

315

# Generate pipe

316

nest generate pipe validation

317

318

# Generate with alias

319

nest g pi parse-int

320

```

321

322

#### Filter Generator

323

324

Creates NestJS exception filters for error handling.

325

326

```typescript { .api }

327

/**

328

* Generate a Nest exception filter

329

* @param options - Filter configuration options

330

* @returns Angular DevKit Rule for filter generation

331

*/

332

function filter(options: FilterOptions): Rule;

333

334

interface FilterOptions extends BaseSchematicOptions {

335

name: string;

336

}

337

```

338

339

**Usage Examples:**

340

341

```bash

342

# Generate filter

343

nest generate filter http-exception

344

345

# Generate with alias

346

nest g f validation

347

```

348

349

#### Middleware Generator

350

351

Creates NestJS middleware for request processing.

352

353

```typescript { .api }

354

/**

355

* Generate a Nest middleware

356

* @param options - Middleware configuration options

357

* @returns Angular DevKit Rule for middleware generation

358

*/

359

function middleware(options: MiddlewareOptions): Rule;

360

361

interface MiddlewareOptions extends BaseSchematicOptions {

362

name: string;

363

}

364

```

365

366

**Usage Examples:**

367

368

```bash

369

# Generate middleware

370

nest generate middleware logger

371

372

# Generate with alias

373

nest g mi cors

374

```

375

376

### Gateway and Real-time Communication

377

378

#### Gateway Generator

379

380

Creates NestJS WebSocket gateways for real-time communication.

381

382

```typescript { .api }

383

/**

384

* Generate a Nest WebSocket gateway

385

* @param options - Gateway configuration options

386

* @returns Angular DevKit Rule for gateway generation

387

*/

388

function gateway(options: GatewayOptions): Rule;

389

390

interface GatewayOptions extends BaseSchematicOptions {

391

name: string;

392

}

393

```

394

395

**Usage Examples:**

396

397

```bash

398

# Generate gateway

399

nest generate gateway chat

400

401

# Generate with alias

402

nest g ga events

403

```

404

405

### GraphQL Integration

406

407

#### Resolver Generator

408

409

Creates GraphQL resolvers for NestJS GraphQL applications.

410

411

```typescript { .api }

412

/**

413

* Generate a GraphQL resolver

414

* @param options - Resolver configuration options

415

* @returns Angular DevKit Rule for resolver generation

416

*/

417

function resolver(options: ResolverOptions): Rule;

418

419

interface ResolverOptions extends BaseSchematicOptions {

420

name: string;

421

}

422

```

423

424

**Usage Examples:**

425

426

```bash

427

# Generate resolver

428

nest generate resolver user

429

430

# Generate with alias

431

nest g r posts

432

```

433

434

### Advanced Generators

435

436

#### Resource Generator

437

438

Creates a complete CRUD resource with controller, service, DTOs, and entities.

439

440

```typescript { .api }

441

/**

442

* Generate a complete CRUD resource

443

* @param options - Resource configuration options

444

* @returns Angular DevKit Rule for resource generation

445

*/

446

function resource(options: ResourceOptions): Rule;

447

448

interface ResourceOptions extends BaseSchematicOptions {

449

name: string;

450

type?: 'rest' | 'graphql-code-first' | 'graphql-schema-first' | 'microservice' | 'ws';

451

crud?: boolean;

452

isSwaggerInstalled?: boolean;

453

}

454

```

455

456

**Usage Examples:**

457

458

```bash

459

# Generate REST resource with CRUD

460

nest generate resource posts --type=rest --crud

461

462

# Generate GraphQL resource

463

nest g res users --type=graphql-code-first

464

465

# Generate microservice resource

466

nest g res orders --type=microservice

467

```

468

469

### Utility and Structure Generators

470

471

#### Class Generator

472

473

Creates generic TypeScript classes.

474

475

```typescript { .api }

476

/**

477

* Generate a TypeScript class

478

* @param options - Class configuration options

479

* @returns Angular DevKit Rule for class generation

480

*/

481

function classGenerator(options: ClassOptions): Rule;

482

483

interface ClassOptions extends BaseSchematicOptions {

484

name: string;

485

}

486

```

487

488

#### Interface Generator

489

490

Creates TypeScript interfaces.

491

492

```typescript { .api }

493

/**

494

* Generate a TypeScript interface

495

* @param options - Interface configuration options

496

* @returns Angular DevKit Rule for interface generation

497

*/

498

function interfaceGenerator(options: InterfaceOptions): Rule;

499

500

interface InterfaceOptions extends BaseSchematicOptions {

501

name: string;

502

}

503

```

504

505

#### Decorator Generator

506

507

Creates custom TypeScript decorators.

508

509

```typescript { .api }

510

/**

511

* Generate a custom decorator

512

* @param options - Decorator configuration options

513

* @returns Angular DevKit Rule for decorator generation

514

*/

515

function decorator(options: DecoratorOptions): Rule;

516

517

interface DecoratorOptions extends BaseSchematicOptions {

518

name: string;

519

}

520

```

521

522

### Client Integration

523

524

#### Angular App Generator

525

526

Creates Angular client applications integrated with NestJS backend.

527

528

```typescript { .api }

529

/**

530

* Generate an Angular client application

531

* @param options - Angular app configuration options

532

* @returns Angular DevKit Rule for Angular app generation

533

*/

534

function angularApp(options: AngularOptions): Rule;

535

536

interface AngularOptions extends BaseSchematicOptions {

537

name: string;

538

}

539

```

540

541

### Configuration

542

543

#### Configuration Generator

544

545

Creates Nest CLI configuration files.

546

547

```typescript { .api }

548

/**

549

* Generate Nest CLI configuration

550

* @param options - Configuration options

551

* @returns Angular DevKit Rule for configuration generation

552

*/

553

function configuration(options: any): Rule;

554

```

555

556

## Common Patterns

557

558

559

### Schematic Aliases

560

561

Most schematics support short aliases for faster CLI usage:

562

563

| Schematic | Alias | Example |

564

|-----------|-------|---------|

565

| `application` | - | `nest g application my-app` |

566

| `class` | `cl` | `nest g cl my-class` |

567

| `controller` | `co` | `nest g co auth` |

568

| `decorator` | `d` | `nest g d custom` |

569

| `filter` | `f` | `nest g f exception` |

570

| `gateway` | `ga` | `nest g ga chat` |

571

| `guard` | `gu` | `nest g gu auth` |

572

| `interceptor` | `itc` | `nest g itc logging` |

573

| `interface` | `itf` | `nest g itf user` |

574

| `library` | `lib` | `nest g lib shared` |

575

| `middleware` | `mi` | `nest g mi cors` |

576

| `module` | `mo` | `nest g mo users` |

577

| `pipe` | `pi` | `nest g pi validation` |

578

| `provider` | `pr` | `nest g pr config` |

579

| `resolver` | `r` | `nest g r user` |

580

| `resource` | `res` | `nest g res posts` |

581

| `service` | `s` | `nest g s users` |

582

| `sub-app` | `app` | `nest g app admin` |

583

584

### Factory Function Pattern

585

586

All schematics follow the Angular DevKit factory pattern:

587

588

```typescript { .api }

589

/**

590

* Factory function pattern for all schematics

591

* @param options - Schematic-specific options

592

* @returns Angular DevKit Rule for tree transformation

593

*/

594

function schematicFactory<T>(options: T): Rule;

595

```