npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@guachos/nestjs-typeorm-schematics

v0.1.1

Published

NestJS CLI Schematics for Custom resources Generation in projects with typeorm pesistence layer

Downloads

74

Readme

Overview

This package contains a set of NestJS CLI schematics for generating custom resources for a nestjs project using typeorm persistent layer

  • crud: fully functional and swagger integrated CRUD module.

TRHANKS!: This solution is inspired in this article, and this, and this repos

See below for a description of the use cases.

Installation

Install the package as dev dependencies below. Due to the implementation of the NestJS CLI, the package can be global or dev.

npm install -D @guachos/nestjs-typeorm-schematics

or

yarn add -D @guachos/nestjs-typeorm-schematics

Dependencies

yarn add typeorm @nestjs/{common,typeorm,swagger} @guachos/{api-core,nestjs-typeorm-data-access,nestjs-typeorm-recipes}

The generated code uses some of the public libraries of the @guachos development ecosystem:

  • @guachos/api-core
  • @guachos/nestjs-api-response
  • @guachos/nestjs-common
  • @guachos/nestjs-typeorm-data-access
  • @guachos/nestjs-typeorm-meta-mapper
  • @guachos/nestjs-typeorm-recipes

NOTE: some of these libraries are currently maintained in private repos, so this solution is not fully open source...for now

Resources Generation

Currently, there is only one case supported, with a corresponding schematic:

  1. Adding a generated CRUD module to an existing NestJS project. In this case, the module is created in its own folder, and is wired into the existing project using appropriate module metadata, includes, etc. This schematic works much like Nest's built-in module schematic but creates a fully implemented CRUD module with Swagger integration and this schematic is based on generated entities.

Nest CLI

These schematics are built on top of the Nest CLI infrastructure, so their usage is exactly as documented on that page.

Note: since these schematics are built on top of the Nest CLI, all of the optional arguments (such as specifying an optional path in which to generate the code) and options (such as --dry-run, --flat) are available. Currently, however, the schematics always generate spec files.

Use the crud schematic

npx nest g -c @guachos/nestjs-typeorm-schematics crud <module-name> <destination-path>
  • crud is the name of the schematic used to generate a new CRUD module (which will be added to your existing project).
  • <module-name> is the name of the new module you're building.
  • <destination-path> is the path where the new module will be generated

TIP: You can simply type nest g -c @guachos/nestjs-typeorm-schematics crud and follow the prompt instructions

The schematic adds the new module in a folder named <module-name>. Just like using the built-in module schematic (e.g., nest g module myNewModule), this will add the generated module to the imports list of your root module with the appropriate metadata and includes. At this point, you can customize the generated module as needed.

Example: Create todo crud module
> npx nest g -c @guachos/nestjs-typeorm-schematics crud               
? Which project would you like to generate to? src [ Default ]
? What name would you like to use for the module? todo
? What path would you like to use for create the module? 
CREATE src/todo/todo.controller.ts (684 bytes)
CREATE src/todo/todo.module.ts (551 bytes)
CREATE src/todo/todo.service.ts (479 bytes)
CREATE src/todo/app/dto/todo.create.dto.ts (550 bytes)
CREATE src/todo/app/dto/todo.update.dto.ts (260 bytes)
CREATE src/todo/app/dto/todo.view.ts (532 bytes)
CREATE src/todo/domain/todo.domain.entity.ts (1893 bytes)
CREATE src/todo/infra/todo.mapper.ts (1079 bytes)
CREATE src/todo/infra/todo.persistence.entity.ts (213 bytes)
CREATE src/todo/infra/todo.repository.ts (451 bytes)
CREATE src/todo/test/todo.controller.spec.ts (548 bytes)
CREATE src/todo/test/todo.service.spec.ts (438 bytes)
UPDATE src/app.module.ts (417 bytes)

More Help

You can also refer to these articles:

Schematics — An Introduction

How to build completely dynamic NestJS modules - for details on the concepts behind the dynamic module pattern.

Built a NestJS module for Knex.js in 5 minutes - an end-to-end tutorial on using these schematics.

Use Angular Schematics to Simplify Your Life

Extend Angular Schematics to customize your development process

How to create your own Angular Schematics

Generating microservices with nestjs and schematics

Change Log

See Changelog for more information.

Author

David Estevez [email protected]

License

Licensed under the MIT License - see the LICENSE file for details.

Project status

This utility generates code that relies on some of the newest features of the @guachos development ecosystem. Several of these features are in an early stage of development.

We will continue to improve and add new features