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

generate-code-ddd

v1.13.0

Published

Generate DDD code

Downloads

8

Readme

GENERATE CODE

install cloen repositoru templeate

npm install -g generate-code-ddd --production

Iniciar un projecto con nest grapql

pre requisitos, para la base de datos se usa firestore, debes tener instalado java

npm install -g firebase-tools @nestjs/cli

iniciamos un proyecto con el CLI de nestjs

nest new my-project
cd my-project
npm install --save @nestjs/cqrs @nestjs/graphql graphql [email protected] class-validator class-transformer base-ddd firebase-admin
npm i faker @types/faker --save-dev

2.- remove generate files

rm src/app.controller.ts && rm src/app.controller.spec.ts && rm src/app.service.ts && rm test/app.e2e-spec.ts

3.- replace src/app.module.ts

import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { CqrsModule } from '@nestjs/cqrs';
import { UserModule } from './user/user.module';
import { ShareModule } from './share/share.module';

@Module({
  imports: [
    GraphQLModule.forRoot({
      autoSchemaFile: true,
      playground: true,
      debug: true,
    }),
    CqrsModule,
    UserModule,
    ShareModule,
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}

4.- replace src/main.ts

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalPipes(
    new ValidationPipe({
      whitelist: true,
      transform: true,
      forbidNonWhitelisted: true,
    }),
  );

  app.enableCors({
    origin: '*',
    methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
    allowedHeaders: 'Content-Type, Accept, Authorization',
  });
  await app.listen(3000);
}

bootstrap();

5 eject CLI GENERATOR

flab

Esto se hace solo una vez se generan lso arhcivos necesario para que el proyecto inicie select aggregate init project

6 generate user crud

flab

Select aggregate user and select "Generate CRUD" select aggregate generate crud

7 opcional

change file ".prettierrc"

{
  "singleQuote": true,
  "trailingComma": "all",
  "printWidth": 120
}

run

make run

open http://localhost:3000/graphql

test

important!! update "package.json" add "--runInBand --verbose" in test:e2e script

"test:e2e": "jest --runInBand --verbose --config ./test/jest-e2e.json"

run test this command run : format, lint, init test and e2e test

make

##End generator




Detail yml

Example

path: src/user
nameSpace: app.user
name: User
properties:
  id: id
  name: string
  lastName:
    type: string
    required: false
  birthdate: date
  emails : string[]
  address: User:Address
  phones: 
    type: User:Phone[]
    min: 1
entity:
  - name: Phone
    properties:
      id: id
      number: integer
valueObject:
  - name: Address
    properties:
      street: string
      number: integer
message:
  User:name:
    required: "El nombre es requerido"
    valid: "El nombre no es un valor válido"
  User:phones:number:
    required: "El numero del celular es requerido"
  User:address:street:
    required: "El nombre de avenida es requerida"
  User:phones:
    min: " al menos un telefono"
event: user
repository:
  pk: id
  table: user
  columnName:
    User:id: id
    User:name: name
    User:lastName: last_name
    User:birthdate: birthdate
    User:emails: emails
    User:address:street: address_street
    User:address:number: address_number
    User:phones: phones

Parámetros

| Param | Description | required | Default | | ----------- | ------------------------------------------------------------- | -------- | --------------------------------- | | path | Ruta donde se va a generar el código | true | -- | | name | Nombre del aggregate | true | -- | | nameSpace | En caso necesario (php, java) | false | "" | | properties | Descripción de propiedades deñ aggregate | true | -- | | entity | Descripción de las entidades del agregate | false | [] | | valueObject | Descripción de los value objects del agregate | false | [] | | messages | mensajes para la validacion de campos | false | generado por el cli | | event | nombre del los eventos que se van a generar | false | nombre del aggregate en minuscula | | repository | configuracion de la base datos | false | generado por el cli |

Parámetro aggregate y voEntity

Se define el nombre y la lista de propiedades

Parámetro properties

| type | required default | default | default values | more config | primitive value | length | db | | ----------- | ------------------ | ------- | ------------------ | -------------------------- | ----------------------- | --------- | ---------- | | id | true (no editable) | -- | -- | -- | string | 36 | string | | string | true | null | empty o text | min, max | string | 255 o máx | string | | text | true | null | empty o text | min, max | string | max | text | | uuid | true | null | random o uuid | -- | string | 36 | string | | date | true | null | now o date | min, max | Date | --- | dateTime | | integer | true | null | zero o int | min, max | Integer | --- | integer | | double | true | null | zero o Double | min, max | Double | --- | double | | enum | true | null | firstValue o value | values | string | --- | string | | entity | true | -- | -- | -- | depende de la entity | --- | relation | | valueObject | true | -- | -- | -- | depende del valueObject | --- | add column | | any[] | true | [] | [] | min, max, eachMin, eachMax | array | --- | json |

[!NOTE] any[] : cuando se pasa un array, la data se guarda en formato json

[!NOTE] entity : en al db se crea una relacion con otra entidad

[!NOTE] valueObject : en al db se crea columnas para guardar la data

id

este parametro es muy poco configurable, es obligatorio y es de tipo uuid

string

type: string
required: false
default: null
min: 3
max: 20
type: string
required: true
default: empty

valueObject

type: User:Address:Name
type: User:Address:Name[]

entity

type: User:Comment
type: User:Comment[]

enum

type: enum
required: true
values: [item1,item2,item3]

Fase 1, se inicia considerando un solo agregate y campos individuales

Example

path: src/user
nameSpace: app.user
name: User
properties:
  id: id
  name: string
  lastName:
    type: string
    required: false
  birthdate: date
message:
  User:name:
    required: "El nombre es requerido"
    valid: "El nombre no es un valor válido"
event: user
repository:
  pk: id
  table: user
  columnName:
    User:id: id
    User:name: name
    User:lastName: last_name
    User:birthdate: birthdate
nest g s modules/load-data/application/ymlToJson

upload test