innovationhub-cli 2.0.2 → 2.1.0
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 +158 -158
- package/package.json +2 -2
- package/templates/nest/jest.config.js +5 -0
- package/templates/nest/package.json +7 -6
- package/templates/nest/src/app.module.ts +4 -6
- package/templates/nest/src/{data-source.ts → core/config/data-source.ts} +2 -2
- package/templates/nest/src/core/database/data-source.ts +23 -0
- package/templates/nest/src/{auth → modules/auth}/auth.controller.ts +2 -2
- package/templates/nest/src/{auth → modules/auth}/auth.module.ts +1 -1
- package/templates/nest/src/{auth → modules/auth}/auth.service.ts +5 -5
- package/templates/nest/src/{auth → modules/auth}/dto/change-password.dto.ts +1 -1
- package/templates/nest/src/{auth → modules/auth}/dto/login-response.dto.ts +1 -1
- package/templates/nest/src/{auth → modules/auth}/entities/refresh-token.entity.ts +2 -2
- package/templates/nest/src/{auth → modules/auth}/strategies/jwt.strategy.ts +2 -2
- package/templates/nest/src/{auth → modules/auth}/strategies/local.strategy.ts +2 -2
- package/templates/nest/src/{user → modules/user}/dto/query-users.dto.ts +1 -1
- package/templates/nest/src/{user → modules/user}/entities/user.entity.ts +3 -3
- package/templates/nest/src/{user → modules/user}/user.controller.ts +5 -5
- package/templates/nest/src/{user → modules/user}/user.repository.ts +2 -2
- package/templates/nest/src/{user → modules/user}/user.service.ts +2 -2
- package/templates/nest/tsconfig.json +6 -0
- package/templates/nest/tsconfig.typeorm.json +8 -0
- package/templates/nest/src/app.controller.ts +0 -7
- package/templates/nest/src/app.service.ts +0 -4
- package/templates/nest/test/jest-e2e.json +0 -12
- /package/templates/nest/src/{common → core/common}/base.entity.ts +0 -0
- /package/templates/nest/src/{common → core/common}/base.repository.ts +0 -0
- /package/templates/nest/src/{common → core/common}/base.service.ts +0 -0
- /package/templates/nest/src/{common → core/common}/constants/errors.constants.ts +0 -0
- /package/templates/nest/src/{common → core/common}/decorators/user.decorator.ts +0 -0
- /package/templates/nest/src/{common → core/common}/dto/base-query.dto.ts +0 -0
- /package/templates/nest/src/{common → core/common}/irepository.ts +0 -0
- /package/templates/nest/src/{common → core/common}/utils/duration.utils.ts +0 -0
- /package/templates/nest/src/{common → core/common}/utils/pagination.utils.ts +0 -0
- /package/templates/nest/src/{common → core/common}/utils/slug.utils.ts +0 -0
- /package/templates/nest/src/{common → core/common}/utils/transform.utils.ts +0 -0
- /package/templates/nest/src/{common → core/common}/validators/is-date-after.validator.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/decorators/roles.decorator.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/dto/login.dto.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/dto/refresh-token.dto.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/enums/role.enum.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/guards/jwt-auth.guard.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/guards/refresh-token.guard.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/guards/roles.guard.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/interfaces/jwt-payload.interface.ts +0 -0
- /package/templates/nest/src/{auth → modules/auth}/strategies/refresh-token.strategy.ts +0 -0
- /package/templates/nest/src/{user → modules/user}/dto/create-user.dto.ts +0 -0
- /package/templates/nest/src/{user → modules/user}/dto/update-user.dto.ts +0 -0
- /package/templates/nest/src/{user → modules/user}/user.module.ts +0 -0
package/README.md
CHANGED
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
# InnovationHub CLI
|
|
2
|
-
|
|
3
|
-
Ferramenta oficial para inicializar projetos Backend na InnovationHub.
|
|
4
|
-
|
|
5
|
-
## Instalação
|
|
6
|
-
|
|
7
|
-
Para usar sem instalar (recomendado):
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npx innovationhub-cli
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Para instalar globalmente:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install -g innovationhub-cli
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Como Usar
|
|
20
|
-
|
|
21
|
-
### Modo Interativo
|
|
22
|
-
|
|
23
|
-
Execute o comando e siga os passos:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
innovationhub
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
O CLI vai guiar você por:
|
|
30
|
-
|
|
31
|
-
1. **Nome do Projeto** — nome da pasta
|
|
32
|
-
2. **Stack** — NestJS ou Python (FastAPI)
|
|
33
|
-
3. **Addons** — recursos opcionais (variam por stack)
|
|
34
|
-
4. **Resumo** — revise e confirme
|
|
35
|
-
5. **Dependências** — instalar automaticamente (opcional)
|
|
36
|
-
|
|
37
|
-
### Modo Direto (CLI Flags)
|
|
38
|
-
|
|
39
|
-
Para automação ou uso rápido via flags:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Criar projeto completo
|
|
43
|
-
innovationhub --name meu-api --stack nest --addons cloudinary,.github --install
|
|
44
|
-
|
|
45
|
-
# Mínimo, sem addons e sem confirmações
|
|
46
|
-
innovationhub -n meu-api -s nest -y
|
|
47
|
-
|
|
48
|
-
# Python com todos os addons
|
|
49
|
-
innovationhub -n minha-api -s python -a cloudinary,.github,pre-commit -i -y
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### Flags Disponíveis
|
|
53
|
-
|
|
54
|
-
| Flag | Short | Descrição |
|
|
55
|
-
| ------------------ | ----- | ------------------------------------- |
|
|
56
|
-
| `--name <nome>` | `-n` | Nome do projeto |
|
|
57
|
-
| `--stack <stack>` | `-s` | Stack (`nest` ou `python`) |
|
|
58
|
-
| `--addons <lista>` | `-a` | Addons separados por vírgula |
|
|
59
|
-
| `--install` | `-i` | Instalar dependências automaticamente |
|
|
60
|
-
| `--yes` | `-y` | Pular confirmações |
|
|
61
|
-
| `--version` | `-v` | Mostrar versão |
|
|
62
|
-
| `--help` | `-h` | Mostrar ajuda |
|
|
63
|
-
|
|
64
|
-
> **Dica:** as flags são opcionais — se faltar alguma, o CLI pergunta interativamente.
|
|
65
|
-
|
|
66
|
-
## Stacks Disponíveis
|
|
67
|
-
|
|
68
|
-
| Stack | Descrição |
|
|
69
|
-
| -------------------- | ------------------------------------------------- |
|
|
70
|
-
| **NestJS** | Backend Node.js com TypeScript, TypeORM, JWT Auth |
|
|
71
|
-
| **Python (FastAPI)** | Backend Python com SQLAlchemy, Alembic, JWT Auth |
|
|
72
|
-
|
|
73
|
-
### Criando Novas Stacks
|
|
74
|
-
|
|
75
|
-
Para adicionar uma nova stack, crie uma pasta em `templates/{nome}/` com um `template.json`:
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"label": "Nome Exibido",
|
|
80
|
-
"description": "Descrição curta da stack"
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
O CLI descobre as stacks automaticamente — sem precisar alterar o código.
|
|
85
|
-
|
|
86
|
-
## Addons por Stack
|
|
87
|
-
|
|
88
|
-
Cada stack possui addons específicos. Ao selecionar uma stack, o CLI mostra apenas os addons disponíveis para ela.
|
|
89
|
-
|
|
90
|
-
**NestJS:**
|
|
91
|
-
|
|
92
|
-
- Cloudinary (Upload de Imagens)
|
|
93
|
-
- GitHub Actions (CI/CD)
|
|
94
|
-
- Husky (Lint & Commits)
|
|
95
|
-
|
|
96
|
-
**Python (FastAPI):**
|
|
97
|
-
|
|
98
|
-
- Cloudinary (Upload de Imagens)
|
|
99
|
-
- GitHub Actions (CI/CD)
|
|
100
|
-
- Pre-commit (Lint & Formatação)
|
|
101
|
-
|
|
102
|
-
### Criando Novos Addons
|
|
103
|
-
|
|
104
|
-
Para adicionar um novo addon a uma stack:
|
|
105
|
-
|
|
106
|
-
1. Crie uma pasta em `templates/{stack}/addons/{nome-do-addon}/`
|
|
107
|
-
2. Adicione a entrada no `templates/{stack}/addons/addons.json`:
|
|
108
|
-
```json
|
|
109
|
-
{
|
|
110
|
-
"name": "nome-do-addon",
|
|
111
|
-
"label": "Nome Amigável",
|
|
112
|
-
"dest": "caminho/destino"
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
O CLI descobre os addons automaticamente — sem precisar alterar o código.
|
|
117
|
-
|
|
118
|
-
## Desenvolvimento
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
# Clone este repositório
|
|
122
|
-
git clone https://github.com/ProHub-Innovation/innovationhub-cli.git
|
|
123
|
-
cd innovationhub-cli
|
|
124
|
-
|
|
125
|
-
# Instale as dependências
|
|
126
|
-
npm install
|
|
127
|
-
|
|
128
|
-
# Link globalmente para testar
|
|
129
|
-
npm link
|
|
130
|
-
|
|
131
|
-
# Rode o comando
|
|
132
|
-
innovationhub
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Publicação
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
# Atualizar versão (semver)
|
|
139
|
-
npm version patch|minor|major
|
|
140
|
-
|
|
141
|
-
# Login no NPM (primeira vez)
|
|
142
|
-
npm login
|
|
143
|
-
|
|
144
|
-
# Publicar
|
|
145
|
-
npm publish --access public
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Os usuários que usam `npx innovationhub-cli` pegarão a nova versão automaticamente.
|
|
149
|
-
|
|
150
|
-
## Autor
|
|
151
|
-
|
|
152
|
-
Desenvolvido por **[Guilherme Araújo](https://github.com/Slotov7)** ·
|
|
153
|
-
|
|
154
|
-
[Liga Acadêmica de Empreendedorismo Innovation Hub](https://github.com/ProHub-Innovation)
|
|
155
|
-
|
|
156
|
-
## Licença
|
|
157
|
-
|
|
158
|
-
[MIT](LICENSE) © 2026 Innovation Hub
|
|
1
|
+
# InnovationHub CLI
|
|
2
|
+
|
|
3
|
+
Ferramenta oficial para inicializar projetos Backend na InnovationHub.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
Para usar sem instalar (recomendado):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx innovationhub-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Para instalar globalmente:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g innovationhub-cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Como Usar
|
|
20
|
+
|
|
21
|
+
### Modo Interativo
|
|
22
|
+
|
|
23
|
+
Execute o comando e siga os passos:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
innovationhub
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
O CLI vai guiar você por:
|
|
30
|
+
|
|
31
|
+
1. **Nome do Projeto** — nome da pasta
|
|
32
|
+
2. **Stack** — NestJS ou Python (FastAPI)
|
|
33
|
+
3. **Addons** — recursos opcionais (variam por stack)
|
|
34
|
+
4. **Resumo** — revise e confirme
|
|
35
|
+
5. **Dependências** — instalar automaticamente (opcional)
|
|
36
|
+
|
|
37
|
+
### Modo Direto (CLI Flags)
|
|
38
|
+
|
|
39
|
+
Para automação ou uso rápido via flags:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Criar projeto completo
|
|
43
|
+
innovationhub --name meu-api --stack nest --addons cloudinary,.github --install
|
|
44
|
+
|
|
45
|
+
# Mínimo, sem addons e sem confirmações
|
|
46
|
+
innovationhub -n meu-api -s nest -y
|
|
47
|
+
|
|
48
|
+
# Python com todos os addons
|
|
49
|
+
innovationhub -n minha-api -s python -a cloudinary,.github,pre-commit -i -y
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### Flags Disponíveis
|
|
53
|
+
|
|
54
|
+
| Flag | Short | Descrição |
|
|
55
|
+
| ------------------ | ----- | ------------------------------------- |
|
|
56
|
+
| `--name <nome>` | `-n` | Nome do projeto |
|
|
57
|
+
| `--stack <stack>` | `-s` | Stack (`nest` ou `python`) |
|
|
58
|
+
| `--addons <lista>` | `-a` | Addons separados por vírgula |
|
|
59
|
+
| `--install` | `-i` | Instalar dependências automaticamente |
|
|
60
|
+
| `--yes` | `-y` | Pular confirmações |
|
|
61
|
+
| `--version` | `-v` | Mostrar versão |
|
|
62
|
+
| `--help` | `-h` | Mostrar ajuda |
|
|
63
|
+
|
|
64
|
+
> **Dica:** as flags são opcionais — se faltar alguma, o CLI pergunta interativamente.
|
|
65
|
+
|
|
66
|
+
## Stacks Disponíveis
|
|
67
|
+
|
|
68
|
+
| Stack | Descrição |
|
|
69
|
+
| -------------------- | ------------------------------------------------- |
|
|
70
|
+
| **NestJS** | Backend Node.js com TypeScript, TypeORM, JWT Auth |
|
|
71
|
+
| **Python (FastAPI)** | Backend Python com SQLAlchemy, Alembic, JWT Auth |
|
|
72
|
+
|
|
73
|
+
### Criando Novas Stacks
|
|
74
|
+
|
|
75
|
+
Para adicionar uma nova stack, crie uma pasta em `templates/{nome}/` com um `template.json`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"label": "Nome Exibido",
|
|
80
|
+
"description": "Descrição curta da stack"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
O CLI descobre as stacks automaticamente — sem precisar alterar o código.
|
|
85
|
+
|
|
86
|
+
## Addons por Stack
|
|
87
|
+
|
|
88
|
+
Cada stack possui addons específicos. Ao selecionar uma stack, o CLI mostra apenas os addons disponíveis para ela.
|
|
89
|
+
|
|
90
|
+
**NestJS:**
|
|
91
|
+
|
|
92
|
+
- Cloudinary (Upload de Imagens)
|
|
93
|
+
- GitHub Actions (CI/CD)
|
|
94
|
+
- Husky (Lint & Commits)
|
|
95
|
+
|
|
96
|
+
**Python (FastAPI):**
|
|
97
|
+
|
|
98
|
+
- Cloudinary (Upload de Imagens)
|
|
99
|
+
- GitHub Actions (CI/CD)
|
|
100
|
+
- Pre-commit (Lint & Formatação)
|
|
101
|
+
|
|
102
|
+
### Criando Novos Addons
|
|
103
|
+
|
|
104
|
+
Para adicionar um novo addon a uma stack:
|
|
105
|
+
|
|
106
|
+
1. Crie uma pasta em `templates/{stack}/addons/{nome-do-addon}/`
|
|
107
|
+
2. Adicione a entrada no `templates/{stack}/addons/addons.json`:
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"name": "nome-do-addon",
|
|
111
|
+
"label": "Nome Amigável",
|
|
112
|
+
"dest": "caminho/destino"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
O CLI descobre os addons automaticamente — sem precisar alterar o código.
|
|
117
|
+
|
|
118
|
+
## Desenvolvimento
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Clone este repositório
|
|
122
|
+
git clone https://github.com/ProHub-Innovation/innovationhub-cli.git
|
|
123
|
+
cd innovationhub-cli
|
|
124
|
+
|
|
125
|
+
# Instale as dependências
|
|
126
|
+
npm install
|
|
127
|
+
|
|
128
|
+
# Link globalmente para testar
|
|
129
|
+
npm link
|
|
130
|
+
|
|
131
|
+
# Rode o comando
|
|
132
|
+
innovationhub
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Publicação
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Atualizar versão (semver)
|
|
139
|
+
npm version patch|minor|major
|
|
140
|
+
|
|
141
|
+
# Login no NPM (primeira vez)
|
|
142
|
+
npm login
|
|
143
|
+
|
|
144
|
+
# Publicar
|
|
145
|
+
npm publish --access public
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Os usuários que usam `npx innovationhub-cli` pegarão a nova versão automaticamente.
|
|
149
|
+
|
|
150
|
+
## Autor
|
|
151
|
+
|
|
152
|
+
Desenvolvido por **[Guilherme Araújo](https://github.com/Slotov7)** · **[Victor Chagas](https://github.com/VictorChagasS)** ·
|
|
153
|
+
|
|
154
|
+
[Liga Acadêmica de Empreendedorismo Innovation Hub](https://github.com/ProHub-Innovation)
|
|
155
|
+
|
|
156
|
+
## Licença
|
|
157
|
+
|
|
158
|
+
[MIT](LICENSE) © 2026 Innovation Hub
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "innovationhub-cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "CLI oficial da InnovationHub para inicializar projetos.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"innovation-hub",
|
|
30
30
|
"backend"
|
|
31
31
|
],
|
|
32
|
-
"author": "Guilherme Araújo",
|
|
32
|
+
"author": "Guilherme Araújo, Victor Chagas",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"type": "module",
|
|
35
35
|
"dependencies": {
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"test:cov": "jest --coverage",
|
|
20
20
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
21
21
|
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
22
|
-
"typeorm": "
|
|
23
|
-
"migration:generate": "
|
|
24
|
-
"migration:create": "
|
|
25
|
-
"migration:run": "
|
|
26
|
-
"migration:revert": "
|
|
27
|
-
"migration:show": "
|
|
22
|
+
"typeorm": "ts-node --project tsconfig.typeorm.json -r tsconfig-paths/register ./node_modules/typeorm/cli.js",
|
|
23
|
+
"migration:generate": "pnpm run typeorm -- migration:generate -d src/core/database/data-source.ts",
|
|
24
|
+
"migration:create": "pnpm run typeorm -- migration:create src/core/database/migrations/",
|
|
25
|
+
"migration:run": "pnpm run typeorm -- migration:run -d src/core/database/data-source.ts",
|
|
26
|
+
"migration:revert": "pnpm run typeorm -- migration:revert -d src/core/database/data-source.ts",
|
|
27
|
+
"migration:show": "pnpm run typeorm -- migration:show -d src/core/database/data-source.ts",
|
|
28
|
+
"seed": "ts-node -r tsconfig-paths/register src/core/database/seeds/seed-admin.ts",
|
|
28
29
|
"prepare": "husky"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Module } from '@nestjs/common';
|
|
2
2
|
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
|
|
3
3
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
4
|
-
import { UserModule } from '
|
|
5
|
-
import { AuthModule } from '
|
|
6
|
-
import { AppController } from './app.controller';
|
|
7
|
-
import { AppService } from './app.service';
|
|
4
|
+
import { UserModule } from '@modules/user/user.module';
|
|
5
|
+
import { AuthModule } from '@modules/auth/auth.module';
|
|
8
6
|
import { MailerModule } from '@nestjs-modules/mailer';
|
|
9
7
|
import { join } from 'path';
|
|
10
8
|
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
|
|
@@ -63,7 +61,7 @@ import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handleba
|
|
|
63
61
|
inject: [ConfigService],
|
|
64
62
|
}),
|
|
65
63
|
],
|
|
66
|
-
controllers: [
|
|
67
|
-
providers: [
|
|
64
|
+
controllers: [],
|
|
65
|
+
providers: [],
|
|
68
66
|
})
|
|
69
67
|
export class AppModule {}
|
|
@@ -10,8 +10,8 @@ export default new DataSource({
|
|
|
10
10
|
username: process.env.DATABASE_USERNAME,
|
|
11
11
|
password: process.env.DATABASE_PASSWORD,
|
|
12
12
|
database: process.env.DATABASE_NAME,
|
|
13
|
-
entities: [__dirname + '
|
|
14
|
-
migrations: ['src/migrations/*.ts'],
|
|
13
|
+
entities: [__dirname + '/../../**/*.entity{.ts,.js}'],
|
|
14
|
+
migrations: ['src/core/database/migrations/*.ts'],
|
|
15
15
|
migrationsTableName: 'migrations',
|
|
16
16
|
synchronize: false,
|
|
17
17
|
ssl:
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm';
|
|
2
|
+
import * as dotenv from 'dotenv';
|
|
3
|
+
|
|
4
|
+
dotenv.config();
|
|
5
|
+
|
|
6
|
+
export default new DataSource({
|
|
7
|
+
type: 'postgres',
|
|
8
|
+
host: process.env.DATABASE_HOST,
|
|
9
|
+
port: Number(process.env.DATABASE_PORT),
|
|
10
|
+
username: process.env.DATABASE_USERNAME,
|
|
11
|
+
password: process.env.DATABASE_PASSWORD,
|
|
12
|
+
database: process.env.DATABASE_NAME,
|
|
13
|
+
entities: [__dirname + '/../../**/*.entity{.ts,.js}'],
|
|
14
|
+
migrations: ['src/core/database/migrations/*.ts'],
|
|
15
|
+
migrationsTableName: 'migrations',
|
|
16
|
+
synchronize: false,
|
|
17
|
+
ssl:
|
|
18
|
+
process.env.DATABASE_SSL === 'true'
|
|
19
|
+
? {
|
|
20
|
+
rejectUnauthorized: false,
|
|
21
|
+
}
|
|
22
|
+
: false,
|
|
23
|
+
});
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
HttpCode,
|
|
8
8
|
HttpStatus,
|
|
9
9
|
} from '@nestjs/common';
|
|
10
|
-
import { User } from '
|
|
11
|
-
import { UserEntity } from '
|
|
10
|
+
import { User } from '@common/decorators/user.decorator';
|
|
11
|
+
import { UserEntity } from '@modules/user/entities/user.entity';
|
|
12
12
|
import {
|
|
13
13
|
ApiTags,
|
|
14
14
|
ApiOperation,
|
|
@@ -3,7 +3,7 @@ import { AuthController } from './auth.controller';
|
|
|
3
3
|
import { AuthService } from './auth.service';
|
|
4
4
|
import { PassportModule } from '@nestjs/passport';
|
|
5
5
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
6
|
-
import { UserModule } from '
|
|
6
|
+
import { UserModule } from '@modules/user/user.module';
|
|
7
7
|
import { JwtModule } from '@nestjs/jwt';
|
|
8
8
|
import { JwtAuthGuard } from './guards/jwt-auth.guard';
|
|
9
9
|
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
@@ -5,19 +5,19 @@ import {
|
|
|
5
5
|
ForbiddenException,
|
|
6
6
|
} from '@nestjs/common';
|
|
7
7
|
import { ConfigService } from '@nestjs/config';
|
|
8
|
-
import { UserService } from '
|
|
8
|
+
import { UserService } from '@modules/user/user.service';
|
|
9
9
|
import { JwtService } from '@nestjs/jwt';
|
|
10
|
-
import { ERRORS } from '
|
|
11
|
-
import { UserEntity } from '
|
|
10
|
+
import { ERRORS } from '@common/constants/errors.constants';
|
|
11
|
+
import { UserEntity } from '@modules/user/entities/user.entity';
|
|
12
12
|
import { ChangePasswordDto } from './dto/change-password.dto';
|
|
13
13
|
import * as bcrypt from 'bcryptjs';
|
|
14
|
-
import { UsersRepository } from '
|
|
14
|
+
import { UsersRepository } from '@modules/user/user.repository';
|
|
15
15
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
16
16
|
import { RefreshTokenEntity } from './entities/refresh-token.entity';
|
|
17
17
|
import { Repository } from 'typeorm';
|
|
18
18
|
import { v4 as uuidv4 } from 'uuid';
|
|
19
19
|
import { LoginResponseDto } from './dto/login-response.dto';
|
|
20
|
-
import { parseDurationToSeconds } from '
|
|
20
|
+
import { parseDurationToSeconds } from '@common/utils/duration.utils';
|
|
21
21
|
|
|
22
22
|
@Injectable()
|
|
23
23
|
export class AuthService {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IsString, MinLength } from 'class-validator';
|
|
2
2
|
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
-
import { ERRORS } from '
|
|
3
|
+
import { ERRORS } from '@common/constants/errors.constants';
|
|
4
4
|
|
|
5
5
|
export class ChangePasswordDto {
|
|
6
6
|
@ApiProperty({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiProperty } from '@nestjs/swagger';
|
|
2
2
|
import { Expose } from 'class-transformer';
|
|
3
|
-
import { UserEntity } from '
|
|
3
|
+
import { UserEntity } from '@modules/user/entities/user.entity';
|
|
4
4
|
|
|
5
5
|
export class LoginResponseDto {
|
|
6
6
|
@ApiProperty()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseEntity } from '
|
|
2
|
-
import { UserEntity } from '
|
|
1
|
+
import { BaseEntity } from '@common/base.entity';
|
|
2
|
+
import { UserEntity } from '@modules/user/entities/user.entity';
|
|
3
3
|
import { Entity, Column, ManyToOne } from 'typeorm';
|
|
4
4
|
|
|
5
5
|
@Entity('refresh_tokens')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
2
|
-
import { ERRORS } from '
|
|
2
|
+
import { ERRORS } from '@common/constants/errors.constants';
|
|
3
3
|
import { PassportStrategy } from '@nestjs/passport';
|
|
4
4
|
import { Strategy, ExtractJwt } from 'passport-jwt';
|
|
5
5
|
import { ConfigService } from '@nestjs/config';
|
|
6
|
-
import { UserService } from '
|
|
6
|
+
import { UserService } from '@modules/user/user.service';
|
|
7
7
|
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class JwtStrategy extends PassportStrategy(Strategy) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
2
|
-
import { ERRORS } from '
|
|
2
|
+
import { ERRORS } from '@common/constants/errors.constants';
|
|
3
3
|
import { PassportStrategy } from '@nestjs/passport';
|
|
4
4
|
import { Strategy } from 'passport-local';
|
|
5
5
|
import { AuthService } from '../auth.service';
|
|
6
|
-
import { UserEntity } from '
|
|
6
|
+
import { UserEntity } from '@modules/user/entities/user.entity';
|
|
7
7
|
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class LocalStrategy extends PassportStrategy(Strategy) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
2
|
import { IsIn, IsOptional, IsString } from 'class-validator';
|
|
3
|
-
import { BaseQueryDto } from '
|
|
3
|
+
import { BaseQueryDto } from '@common/dto/base-query.dto';
|
|
4
4
|
|
|
5
5
|
export class QueryUsersDto extends BaseQueryDto {
|
|
6
6
|
@ApiPropertyOptional({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Column, DeleteDateColumn, Entity, OneToMany } from 'typeorm';
|
|
2
2
|
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
-
import { Role } from '
|
|
3
|
+
import { Role } from '@modules/auth/enums/role.enum';
|
|
4
4
|
import { Exclude, Expose } from 'class-transformer';
|
|
5
|
-
import { BaseEntity } from '
|
|
6
|
-
import { RefreshTokenEntity } from '
|
|
5
|
+
import { BaseEntity } from '@common/base.entity';
|
|
6
|
+
import { RefreshTokenEntity } from '@modules/auth/entities/refresh-token.entity';
|
|
7
7
|
|
|
8
8
|
@Entity('users')
|
|
9
9
|
@Exclude()
|
|
@@ -13,16 +13,16 @@ import {
|
|
|
13
13
|
Req,
|
|
14
14
|
Delete,
|
|
15
15
|
} from '@nestjs/common';
|
|
16
|
-
import { ERRORS } from '
|
|
16
|
+
import { ERRORS } from '@common/constants/errors.constants';
|
|
17
17
|
import { ApiTags, ApiOperation, ApiResponse, ApiBody } from '@nestjs/swagger';
|
|
18
18
|
import { UserService } from './user.service';
|
|
19
19
|
import { UserEntity } from './entities/user.entity';
|
|
20
20
|
import { UpdateUserDto } from './dto/update-user.dto';
|
|
21
|
-
import { JwtAuthGuard } from '
|
|
21
|
+
import { JwtAuthGuard } from '@modules/auth/guards/jwt-auth.guard';
|
|
22
22
|
import { CreateUserDto } from './dto/create-user.dto';
|
|
23
|
-
import { RolesGuard } from '
|
|
24
|
-
import { Roles } from '
|
|
25
|
-
import { Role } from '
|
|
23
|
+
import { RolesGuard } from '@modules/auth/guards/roles.guard';
|
|
24
|
+
import { Roles } from '@modules/auth/decorators/roles.decorator';
|
|
25
|
+
import { Role } from '@modules/auth/enums/role.enum';
|
|
26
26
|
import { QueryUsersDto } from './dto/query-users.dto';
|
|
27
27
|
|
|
28
28
|
@ApiTags('users')
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
3
|
import { Brackets, Repository, IsNull } from 'typeorm';
|
|
4
|
-
import { BaseRepository } from '
|
|
4
|
+
import { BaseRepository } from '@common/base.repository';
|
|
5
5
|
import { UserEntity } from './entities/user.entity';
|
|
6
6
|
import { QueryUsersDto } from './dto/query-users.dto';
|
|
7
|
-
import { buildPaginationMeta } from '
|
|
7
|
+
import { buildPaginationMeta } from '@common/utils/pagination.utils';
|
|
8
8
|
|
|
9
9
|
@Injectable()
|
|
10
10
|
export class UsersRepository extends BaseRepository<UserEntity> {
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
InternalServerErrorException,
|
|
5
5
|
NotFoundException,
|
|
6
6
|
} from '@nestjs/common';
|
|
7
|
-
import { ERRORS } from '
|
|
7
|
+
import { ERRORS } from '@common/constants/errors.constants';
|
|
8
8
|
import { UserEntity } from './entities/user.entity';
|
|
9
9
|
import * as bcrypt from 'bcryptjs';
|
|
10
10
|
import { CreateUserDto } from './dto/create-user.dto';
|
|
11
11
|
import { ConfigService } from '@nestjs/config';
|
|
12
12
|
import { QueryUsersDto } from './dto/query-users.dto';
|
|
13
13
|
import { UsersRepository } from './user.repository';
|
|
14
|
-
import { BaseService } from '
|
|
14
|
+
import { BaseService } from '@common/base.service';
|
|
15
15
|
import { UpdateUserDto } from './dto/update-user.dto';
|
|
16
16
|
|
|
17
17
|
@Injectable()
|
|
@@ -14,12 +14,18 @@
|
|
|
14
14
|
"sourceMap": true,
|
|
15
15
|
"outDir": "./dist",
|
|
16
16
|
"baseUrl": "./",
|
|
17
|
+
"paths": {
|
|
18
|
+
"@common/*": ["src/core/common/*"],
|
|
19
|
+
"@core/*": ["src/core/*"],
|
|
20
|
+
"@modules/*": ["src/modules/*"]
|
|
21
|
+
},
|
|
17
22
|
"incremental": true,
|
|
18
23
|
"skipLibCheck": true,
|
|
19
24
|
"strictNullChecks": true,
|
|
20
25
|
"forceConsistentCasingInFileNames": true,
|
|
21
26
|
"noImplicitAny": false,
|
|
22
27
|
"strictBindCallApply": false,
|
|
28
|
+
"strictPropertyInitialization": false,
|
|
23
29
|
"noFallthroughCasesInSwitch": false
|
|
24
30
|
}
|
|
25
31
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|