#Custom schema for nest -g

4 messages · Page 1 of 1 (latest)

untold sparrow
#

Hello !

I wanted to make my own nest package, to custom the schema nest -generate resource, to make a custom CRUD (that call my real DB service + my basic DTO + remove some lines)
But I don't really know how to do it, do I have to fork the project ?

I C/C the source code for the resource schema, but the imports does not work:

import {
  addPackageJsonDependency, -> Module '"@nestjs/schematics"' has no exported member 'addPackageJsonDependency'.ts(2305)
  DeclarationOptions,
  getPackageJsonDependency, -> Module '"@nestjs/schematics"' has no exported member 'getPackageJsonDependency'.ts(2305)
  Location,
  mergeSourceRoot,
  ModuleDeclarator,
  ModuleFinder,
  NameParser,
  NodeDependencyType, -> Module '"@nestjs/schematics"' has no exported member 'NodeDependencyType'.ts(2305)
  normalizeToKebabOrSnakeCase,
  ResourceOptions, -> Module '"@nestjs/schematics"' has no exported member 'ResourceOptions'.ts(2305)
} from '@nestjs/schematics';

Thank you !

shell oriole
#

I know at the least you can do something like this:
nest generate --collection [collectionName] [resourceName] with your custom collection. I'm not sure how to get it added so it's recognized by default and I've wondered how to do the same.

#

My hunch is that you would have to create some sort of file that imports both @nestjs/schematics and your custom schematics and then have that file referenced in the collection attribute of nest-cli.json

#

But I haven't messed around with it enough yet to figure it out. If anyone knows how to do this I'd be interested to hear.