Skip to content

Commit

Permalink
feat: update CLI middleware scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
rsaz committed Mar 6, 2024
1 parent 9c74b58 commit 8491480
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 42 deletions.
45 changes: 24 additions & 21 deletions docs/cli/generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ expressots g <resource> <structure>

We provide two different structures to scaffold the resources:

- **[entity-action]**: `expressots generate service user-create`
This will create this folder structure: `/user/create` and the file: `user-create.[resource].ts`
- **[entity-action]**: `expressots generate service user-create`
This will create this folder structure: `/user/create` and the file: `user-create.[resource].ts`

- **[folder/subfolder/resource]**: `expressots generate service user/create`
This will create this folder structure: `/user/create` and the file: `create.[resource].ts`
- **[folder/subfolder/resource]**: `expressots generate service user/create`
This will create this folder structure: `/user/create` and the file: `create.[resource].ts`

If you add `/` at the end of the structure, the CLI will create the resource inside of the folder. Example: `expressots generate service user/create/`
Structure: `user/create/` and the file: `create.[resource].ts`
If you add `/` at the end of the structure, the CLI will create the resource inside of the folder. Example: `expressots generate service user/create/`
Structure: `user/create/` and the file: `create.[resource].ts`

### Resource Root Folder

- The root folder for all resources is the `src` folder. This can be changed in the `expressots.config.ts` file.
- In the opinionated mode, the root folder is the `src` folder and the resources scaffolded with `service, usecase, dto, controller` are created inside of the `useCases` folder.
- Entities are created inside of the `entities` folder, and providers inside of the `providers` folder.
- The root folder for all resources is the `src` folder. This can be changed in the `expressots.config.ts` file.
- In the opinionated mode, the root folder is the `src` folder and the resources scaffolded with `service, usecase, dto, controller` are created inside of the `useCases` folder.
- Entities are created inside of the `entities` folder, and providers inside of the `providers` folder.

## Resource Types

Expand All @@ -53,6 +53,7 @@ Current available resources:
| provider | p |
| service | s |
| entity | e |
| middleware | m |

## Usage Example

Expand All @@ -63,6 +64,8 @@ Current available resources:
| expressots g d user/find | DTO to be created in the folder `useCases` inside of user/find |
| expressots g p email/email | Provider to be created in the folder `providers` inside of user/find |
| expressots g s user/find | Service creates usecase, controller and DTO and add them in the desired folder user/find |
| expressots g e user | Entity to be created in the folder `entities` with this folder structure: user |
| expressots g m auth | Middleware to be created in the folder `middlewares` with this folder structure: auth |

All resources can be created using the structure `folder/subfolder/resource`.

Expand All @@ -86,17 +89,17 @@ Here is the current configuration file with all the available options:
import { ExpressoConfig, Pattern } from "@expressots/core";

const config: ExpressoConfig = {
sourceRoot: "src",
scaffoldPattern: Pattern.KEBAB_CASE,
opinionated: false,
sourceRoot: "src",
scaffoldPattern: Pattern.KEBAB_CASE,
opinionated: false,
};

export default config;
```

- **sourceRoot**: the root folder that will be used by the CLI to create the resources. Default: `src`
- **scaffoldPattern**: the pattern that will be used to create the resources. Default: `Pattern.KEBAB_CASE`. Example: `user-create`
- **opinionated**: if true, the CLI will create the resources using the opinionated folder structure
- **sourceRoot**: the root folder that will be used by the CLI to create the resources. Default: `src`
- **scaffoldPattern**: the pattern that will be used to create the resources. Default: `Pattern.KEBAB_CASE`. Example: `user-create`
- **opinionated**: if true, the CLI will create the resources using the opinionated folder structure

## Recommendations

Expand All @@ -108,9 +111,9 @@ Try to use as many different forms of creating resources as possible. This will

ExpressoTS is an MIT-licensed open source project. It's an independent project with ongoing development made possible thanks to your support. If you'd like to help, please consider:

- Become a **[sponsor on GitHub](https://github.com/sponsors/expressots)**
- Follow the **[organization](https://github.com/expressots)** on GitHub and Star ⭐ the project
- Subscribe to the Twitch channel: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
- Join our **[Discord](https://discord.com/invite/PyPJfGK)**
- Contribute submitting **[issues and pull requests](https://github.com/expressots/expressots/issues/new/choose)**
- Share the project with your friends and colleagues
- Become a **[sponsor on GitHub](https://github.com/sponsors/expressots)**
- Follow the **[organization](https://github.com/expressots)** on GitHub and Star ⭐ the project
- Subscribe to the Twitch channel: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
- Join our **[Discord](https://discord.com/invite/PyPJfGK)**
- Contribute submitting **[issues and pull requests](https://github.com/expressots/expressots/issues/new/choose)**
- Share the project with your friends and colleagues
45 changes: 24 additions & 21 deletions i18n/pt/docusaurus-plugin-content-docs/current/cli/generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ expressots g <recurso> <estrutura>

Nós fornecemos duas estruturas diferentes para estruturar os recursos:

- **[entidade-ação]**: `expressots generate service user-create`
Isso criará esta estrutura de pastas: `/user/create` e o arquivo: `user-create.[recurso].ts`
- **[entidade-ação]**: `expressots generate service user-create`
Isso criará esta estrutura de pastas: `/user/create` e o arquivo: `user-create.[recurso].ts`

- **[pasta/subpasta/recurso]**: `expressots generate service user/create`
Isso criará esta estrutura de pastas: `/user/create` e o arquivo: `create.[recurso].ts`
- **[pasta/subpasta/recurso]**: `expressots generate service user/create`
Isso criará esta estrutura de pastas: `/user/create` e o arquivo: `create.[recurso].ts`

Se você adicionar `/` no final da estrutura, o CLI criará o recurso dentro da pasta. Exemplo: `expressots generate service user/create/`
Estrutura: `user/create/` e o arquivo: `create.[recurso].ts`
Se você adicionar `/` no final da estrutura, o CLI criará o recurso dentro da pasta. Exemplo: `expressots generate service user/create/`
Estrutura: `user/create/` e o arquivo: `create.[recurso].ts`

### Pasta raiz do recurso

- A pasta raiz de todos os recursos é a `src`. Isso pode ser alterado no arquivo `expressots.config.ts`.
- No modo opinativo, a pasta raiz é o `src` e os recursos montados com `service, usecase, dto, controller` são criados dentro do `useCases`.
- As entidades são criadas dentro do `entities`, e provedores dentro do `providers`.
- A pasta raiz de todos os recursos é a `src`. Isso pode ser alterado no arquivo `expressots.config.ts`.
- No modo opinativo, a pasta raiz é o `src` e os recursos montados com `service, usecase, dto, controller` são criados dentro do `useCases`.
- As entidades são criadas dentro do `entities`, e provedores dentro do `providers`.

## Tipos de recursos

Expand All @@ -53,6 +53,7 @@ Recursos atualmente disponíveis para serem gerados:
| provider | p |
| service | s |
| entity | e |
| middleware | m |

## Exemplo de uso

Expand All @@ -63,6 +64,8 @@ Recursos atualmente disponíveis para serem gerados:
| expressots g d user/find | DTO a ser criado na pasta `useCases` dentro de user/find |
| expressots g p email/email | Provedor a ser criado na pasta `providers` dentro de user/find |
| expressots g s user/find | Serviço cria caso de uso, controladora e dto e os adiciona na pasta user/find |
| expressots g e user | Entidade a ser criada na pasta `entities` com esta estrutura de pasta: user |
| expressots g m auth | Middleware a ser criado na pasta `middlewares` com esta estrutura de pasta: auth |

Todos os recursos podem ser criados usando a estrutura `pasta/subpasta/recurso.`

Expand All @@ -86,17 +89,17 @@ Aqui está o arquivo de configuração atual com todas as opções disponíveis:
import { ExpressoConfig, Pattern } from "@expressots/core";

const config: ExpressoConfig = {
sourceRoot: "src",
scaffoldPattern: Pattern.KEBAB_CASE,
opinionated: false,
sourceRoot: "src",
scaffoldPattern: Pattern.KEBAB_CASE,
opinionated: false,
};

export default config;
```

- **sourceRoot**: a pasta raiz que será usada pelo CLI para criar os recursos. Padrão: `src`
- **scaffoldPattern**: o padrão que será usado para criar os recursos. Padrão: `Pattern.KEBAB_CASE`. Exemplo: `user-create`
- **opinionated**: se for verdadeiro, o CLI criará os recursos usando a estrutura de pasta com opinião.
- **sourceRoot**: a pasta raiz que será usada pelo CLI para criar os recursos. Padrão: `src`
- **scaffoldPattern**: o padrão que será usado para criar os recursos. Padrão: `Pattern.KEBAB_CASE`. Exemplo: `user-create`
- **opinionated**: se for verdadeiro, o CLI criará os recursos usando a estrutura de pasta com opinião.

## Recomendações

Expand All @@ -108,9 +111,9 @@ Tente utilizar o maior número possível de formas de criação de recursos disp

ExpressoTS é um projeto de código aberto licenciado sob o MIT. É um projeto independente com desenvolvimento contínuo possibilitado graças ao seu suporte. Se você deseja ajudar, por favor considere:

- Se tornar um **[Sponsor no GitHub](https://github.com/sponsors/expressots)**
- Siga a **[organização](https://github.com/expressots)** no GitHub e de um Star ⭐ no projeto
- Subscreva no nosso canal na Twitch: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
- Entre no nosso **[Discord](https://discord.com/invite/PyPJfGK)**
- Contribua submetendo **[issues e pull requests](https://github.com/expressots/expressots/issues/new/choose)**
- Compartilhe o projeto com seus amigos e colegas
- Se tornar um **[Sponsor no GitHub](https://github.com/sponsors/expressots)**
- Siga a **[organização](https://github.com/expressots)** no GitHub e de um Star ⭐ no projeto
- Subscreva no nosso canal na Twitch: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
- Entre no nosso **[Discord](https://discord.com/invite/PyPJfGK)**
- Contribua submetendo **[issues e pull requests](https://github.com/expressots/expressots/issues/new/choose)**
- Compartilhe o projeto com seus amigos e colegas

0 comments on commit 8491480

Please sign in to comment.