@koalarx/nest-cli 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,17 +1,42 @@
1
1
  # @koalarx/nest-cli
2
2
 
3
- Biblioteca de CLI para criação de projetos utilizando Koala Nest
3
+ Ferramenta oficial de CLI para scaffolding rápido de projetos NestJS estruturados com padrões DDD.
4
4
 
5
- ## Instalação
5
+ ## 📋 Sobre
6
+
7
+ `@koalarx/nest-cli` é a forma recomendada para inicializar novos projetos que utilizam a biblioteca [@koalarx/nest](https://github.com/igordrangel/koala-nest). Cria automaticamente a estrutura de diretórios, configurações de ambiente e setup inicial.
8
+
9
+ ## 📦 Instalação
6
10
 
7
11
  ```bash
8
- npm i -g @koalarx/nest-cli
12
+ npm install -g @koalarx/nest-cli
9
13
  ```
10
14
 
11
- > Versão do Node >= 20.18.0
15
+ **Requisito:** Node.js 20.18.0+
12
16
 
13
- ## Uso
17
+ ## 🚀 Uso Rápido
14
18
 
15
19
  ```bash
16
- koala-nest new app-demo
20
+ # Criar novo projeto
21
+ koala-nest new meu-projeto
22
+
23
+ # Entrar no diretório
24
+ cd meu-projeto
25
+
26
+ # Instalar dependências
27
+ npm install
28
+
29
+ # Iniciar desenvolvimento
30
+ npm run start:dev
17
31
  ```
32
+
33
+ ## 📖 Documentação Completa
34
+
35
+ Para guias detalhados, exemplos avançados e referência de features, consulte:
36
+
37
+ - **[@koalarx/nest](https://github.com/igordrangel/koala-nest)** — Documentação da biblioteca principal
38
+ - **[Exemplo de Projeto](./code-base/startup-project)** — Estrutura padrão gerada pela CLI
39
+
40
+ ## 📄 Licença
41
+
42
+ MIT
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@koalarx/utils": "^4.2.1",
24
- "@koalarx/nest": "^1.16.0",
24
+ "@koalarx/nest": "^1.16.1",
25
25
  "@nestjs/common": "^11.0.12",
26
26
  "@nestjs/config": "^4.0.1",
27
27
  "@nestjs/core": "^11.0.12",
@@ -29,7 +29,8 @@
29
29
  "@nestjs/passport": "^11.0.5",
30
30
  "@nestjs/platform-express": "^11.0.12",
31
31
  "@nestjs/swagger": "^11.0.7",
32
- "@prisma/client": "^6.5.0",
32
+ "@prisma/adapter-pg": "^7.2.0",
33
+ "@prisma/client": "^7.2.0",
33
34
  "@scalar/nestjs-api-reference": "^0.4.3",
34
35
  "dotenv": "^16.0.3",
35
36
  "express-basic-auth": "^1.2.1",
@@ -66,7 +67,7 @@
66
67
  "eslint-plugin-vitest": "^0.2.8",
67
68
  "eslint-plugin-vitest-globals": "^1.4.0",
68
69
  "prettier": "^2.3.2",
69
- "prisma": "^6.5.0",
70
+ "prisma": "^7.2.0",
70
71
  "source-map-support": "^0.5.20",
71
72
  "supertest": "^7.1.0",
72
73
  "tsconfig-paths": "^4.2.0",
@@ -4,9 +4,7 @@ generator client {
4
4
  }
5
5
 
6
6
  datasource db {
7
- provider = "postgresql"
8
- url = env("DATABASE_URL")
9
- directUrl = env("DIRECT_URL")
7
+ provider = "postgresql"
10
8
  }
11
9
 
12
10
  model Person {
@@ -0,0 +1,8 @@
1
+ import 'dotenv/config'
2
+ import { defineConfig, env } from 'prisma/config'
3
+
4
+ export default defineConfig({
5
+ datasource: {
6
+ url: env('DATABASE_URL'),
7
+ },
8
+ })
@@ -5,9 +5,9 @@ import { Injectable } from '@nestjs/common'
5
5
  import { InactivePersonEvent } from './inactive-person-event'
6
6
 
7
7
  @Injectable()
8
- export class InactivePersonHandler extends EventHandlerBase<InactivePersonEvent> {
8
+ export class InactivePersonHandler extends EventHandlerBase {
9
9
  constructor(private readonly repository: IPersonRepository) {
10
- super()
10
+ super(InactivePersonEvent)
11
11
  }
12
12
 
13
13
  async handleEvent(): Promise<void> {
@@ -5,7 +5,7 @@ import { Type } from '@nestjs/common'
5
5
  import { InactivePersonHandler } from './inactive-person/inactive-person-handler'
6
6
 
7
7
  export class PersonEventJob extends EventJob<Person> {
8
- defineHandlers(): Type<EventHandlerBase<any>>[] {
8
+ defineHandlers(): Type<EventHandlerBase>[] {
9
9
  return [InactivePersonHandler]
10
10
  }
11
11
  }
@@ -6,6 +6,7 @@ import { PERSON_ROUTER_CONFIG } from './router.config'
6
6
  describe(`CRUD OF PERSON`, () => {
7
7
  let app: INestApplication
8
8
  let personId: number
9
+ let addressId: number
9
10
 
10
11
  beforeAll(async () => {
11
12
  app = await createE2ETestApp()
@@ -35,13 +36,16 @@ describe(`CRUD OF PERSON`, () => {
35
36
  `${PERSON_ROUTER_CONFIG.group}/${personId}`,
36
37
  )
37
38
 
39
+ // Capturar o ID do endereço da resposta
40
+ addressId = response.body.address.id
41
+
38
42
  expect(response.statusCode).toBe(200)
39
43
  expect(response.body).toStrictEqual({
40
44
  id: personId,
41
45
  name: 'John Doe',
42
46
  phones: [],
43
47
  address: {
44
- id: 1,
48
+ id: expect.any(Number),
45
49
  address: 'Streat 1',
46
50
  },
47
51
  active: true,
@@ -61,7 +65,7 @@ describe(`CRUD OF PERSON`, () => {
61
65
  name: 'John Doe',
62
66
  phones: [],
63
67
  address: {
64
- id: 1,
68
+ id: addressId,
65
69
  address: 'Streat 1',
66
70
  },
67
71
  active: true,
@@ -96,7 +100,7 @@ describe(`CRUD OF PERSON`, () => {
96
100
  name: 'John Doe',
97
101
  phones: [],
98
102
  address: {
99
- id: 1,
103
+ id: addressId,
100
104
  address: 'Streat 1',
101
105
  },
102
106
  active: true,
@@ -113,7 +117,7 @@ describe(`CRUD OF PERSON`, () => {
113
117
  name: 'John Doe Updated',
114
118
  phones: [],
115
119
  address: {
116
- id: 1,
120
+ id: addressId,
117
121
  address: 'Streat 2',
118
122
  },
119
123
  active: true,
@@ -130,7 +134,7 @@ describe(`CRUD OF PERSON`, () => {
130
134
  name: 'John Doe Updated',
131
135
  phones: [],
132
136
  address: {
133
- id: 1,
137
+ id: addressId,
134
138
  address: 'Streat 2',
135
139
  },
136
140
  active: true,
@@ -1,12 +1,23 @@
1
+ import 'dotenv/config'
1
2
  import { CreatePersonJob } from '@/application/person/create-person-job/create-person-job'
2
3
  import { DeleteInactiveJob } from '@/application/person/delete-inative-job/delete-inactive-job'
3
4
  import { InactivePersonHandler } from '@/application/person/events/inactive-person/inactive-person-handler'
4
5
  import { DbTransactionContext } from '@/infra/database/db-transaction-context'
5
6
  import { KoalaApp } from '@koalarx/nest/core/koala-app'
7
+ import { setPrismaClientOptions } from '@koalarx/nest/core/database/prisma.service'
8
+ import { PrismaPg } from '@prisma/adapter-pg'
9
+ import { Pool } from 'pg'
6
10
  import { NestFactory } from '@nestjs/core'
7
11
  import { AppModule } from './app.module'
8
12
 
9
13
  async function bootstrap() {
14
+ // Configurar o adapter PostgreSQL antes de inicializar a aplicação
15
+ const pool = new Pool({
16
+ connectionString: process.env.DATABASE_URL,
17
+ })
18
+ const adapter = new PrismaPg(pool)
19
+ setPrismaClientOptions({ adapter })
20
+
10
21
  return NestFactory.create(AppModule).then((app) =>
11
22
  new KoalaApp(app)
12
23
  .useDoc({
@@ -1,9 +1,20 @@
1
+ import 'dotenv/config'
1
2
  import { AppModule } from '@/host/app.module'
2
3
  import { DbTransactionContext } from '@/infra/database/db-transaction-context'
3
4
  import { KoalaAppTest } from '@koalarx/nest/test/koala-app-test'
5
+ import { setPrismaClientOptions } from '@koalarx/nest/core/database/prisma.service'
6
+ import { PrismaPg } from '@prisma/adapter-pg'
7
+ import { Pool } from 'pg'
4
8
  import { Test } from '@nestjs/testing'
5
9
 
6
10
  export async function createE2ETestApp() {
11
+ // Configurar o adapter PostgreSQL antes de criar o módulo de teste
12
+ const pool = new Pool({
13
+ connectionString: process.env.DATABASE_URL,
14
+ })
15
+ const adapter = new PrismaPg(pool)
16
+ setPrismaClientOptions({ adapter })
17
+
7
18
  return Test.createTestingModule({ imports: [AppModule] })
8
19
  .compile()
9
20
  .then((moduleRef) => moduleRef.createNestApplication())
package/index.js CHANGED
@@ -30,7 +30,7 @@ var import_inquirer = __toESM(require("inquirer"));
30
30
  // package.json
31
31
  var package_default = {
32
32
  name: "@koalarx/nest-cli",
33
- version: "1.1.2",
33
+ version: "1.1.4",
34
34
  description: "Biblioteca de CLI para cria\xE7\xE3o de projetos utilizando Koala Nest",
35
35
  scripts: {
36
36
  test: "vitest run",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalarx/nest-cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Biblioteca de CLI para criação de projetos utilizando Koala Nest",
5
5
  "scripts": {
6
6
  "test": "vitest run",